Help

Built with Seam

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.

The scenario

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.

The solution

You've got two options:

  1. Ensure that you are in a long-running conversation that spans the both the select list creation and the submission of the form.
  2. Use key equality rather than object equality (make equals return true if both objects have the same natural or business key). It's important to note that basing equality on surrogate key identity isn't recommended. You can read more here

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.

Alternative solutions

The knowledge base article Drop-down boxes with entities and page scope describes a feasible workaround.