You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.
JSF runs the converter and loads the entity from the persistence context; JSF runs any validators, and adds it's own - that the selected object must be in the original list; the validation fails as a new object has been loaded from the persistence context.
A more detailed explanation can be found on Drop-down boxes with entities and page scope.
You've got two options:
Which approach should you take? The second solution is the simplest to understand but sometimes it is hard (or not possible) to define a natural key so you'll need to use the first solution.
The knowledge base article Drop-down boxes with entities and page scope describes a feasible workaround.
Would you please post some of the samples with entity bean, stateful session bean action method and xhtml using selectOneMenu and convertEntity
Thanks a lot,
Weiwei Chi
...some examples would be REALLY helpful :)
I had this trouble in my case was in my equals method:
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; MyClass other = (MyClass) obj; if (codigo == null) { if (other.codigo != null) return false; } else if (!codigo.equals(other.codigo)) return false; return true; }in this line:
if (getClass() != obj.getClass()) return false;Cause the obj.getClass() is created via Proxy they don't have same types. If your problem is the same, remove that line and your select will be OK.