3 Replies Latest reply on Oct 12, 2007 12:32 PM by Alex Ka

    h:selectManyListbox and s:convertEntity don't do the job

    Alex Ka Novice

      Hi,
      A colleague today showed me a problem with a page in our application (Seam 2.0.0.B1). When a user opens an Exam he previously created for editing, there is a list (SelectManyListbox) of providers he can select from. Saving the form without modifying the selected (two) items, results in a delete sql for the selected items and two insert SQLs that have exactly the same values.

      What is causing this, in my opinion, is the fact that after submit exam.setProviderList() is called with an Arrays$ArrayList and the PersistentBag that was previously set for the Exam entity is left unassigned.

      Here is the code for the selectManyListbox :

      <h:selectManyListbox id="providerList" value="#{exam.providerList}" styleClass="field" required="true">
       <s:selectItems value="#{providers}" var="p" label="#{p.name}"/>
       <s:convertEntity />
      </h:selectManyListbox>


      I thought convertEntity should do the job but it is only used to convert the entities contained in the list as stated here:
      http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/faces/component/UISelectMany.html

      My solution for the problem would be to create a getter/setter in the ExamAction session bean. The setter would update exam.getProviderList() so that it ends up with the same elements as the passed providerList (which is an Arrays$ArrayList). This solution though seems not seamless. Shouldn't this feature be built-in for the framework?


      There is a wiki page about the entityConverter but the example on selectManyListbox and Factory is really vague. It's not in the source code provided:
      http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamEntityConverter

      Thanks in advance for your comments.