3 Replies Latest reply on Dec 15, 2007 5:39 AM by Saeed Iqbal

    SelectOneMenu problem

    Francis LIMOUSY Newbie

      Hello,

      I make a second post following hager's one as we have new informations about our problem.
      The problem is about a datatable and a selectOneMenu.
      The objects in the selectOneMenu can be added to the table, creating a new line (and vice-versa, a line in the datatable can be removed and goes back in the selectOneMenu)

      On the business side we have two lists

      - one representing the actual lines of the dataTable

      private List<Assignable> lignes;
      
       public List<Assignable> getLignes()
       {
       return this.lignes;
       }
      
       public void setLignes(List<Assignable> lignes)
       {
       this.lignes = lignes;
       }
      


      - and another representing the lines availables for adding (the lines in the selectOneMenu)

       private List<Assignable> availableLines;
      
       public List<Assignable> getAvailableLines()
       {
       return availableLines;
       }
      
       public void setAvailableLines(List<Assignable> availableLines)
       {
       this.availableLines = availableLines;
       }
      



      On the view side we have:

       <h:selectOneMenu id="selectOneAssignable"
       value="#{activitesByCollaborateurCrossData.selectedAssignable}"
       converter="#{activitesByCollaborateurCrossData.assignableConverter}">
       <s:selectItems
       value="#{activitesByCollaborateurCrossData.availableLines}"
       var="assign" label="#{assign.designation}"
       id="selectAssignable" />
      
       </h:selectOneMenu>
       <h:commandLink action="#{activitesByCollaborateurCrossData.addAssignable}">
       <h:graphicImage value="img/add.png" />
       <s:conversationId />
       </h:commandLink>
      



      The problem is: when we add a line using the button, the line is actually added to the datatable, moved from one list to another in the business side (we have checked this in debug) and the getter returns the list for the selectOneMenu without the selectedObject.

      But in the view the object is still in the options of the selectOneMenu !

      And, of course, when we try to do something else, adding another line, doing something else in the page, etc ... there is an error in the log :

      sourceId=activitesByCollaborateurCrossDataForm:selectOneAssignable[severity=(ERROR 2), summary=(Valeur invalide), detail=(Valeur invalide)]
      
      ("Invalid Data" localized)
      


      which looks normal because the model and the view are "desynchronized" on this list.

      After the "try an action - get the invaid data error" routine, the list is correctly displayed in the selectOneMenu and we can add another line, as the model and the view are once again "synchronized" I guess.
      But adding another line repeats the problem ... etc ...

      Our bean is a stateful one:
      @Stateful
      @Scope(ScopeType.CONVERSATION)
      @Name("activitesByCollaborateurCrossData")
      public class activitesByCollaborateurCrossDataBean implements activitesByCollaborateurCrossData {
      


      I initially thought it was a converting issue, as "Assignable" is interface, so I created a converter that handle all the objects implementing the interface, but it didn't change anything.

      The most annoying stuff is the same code was actually working in seam 1.2
      The error appeared after upgrading to Seam 2.0.0.GA + JBoss 4.2.1

      Does anyone have an idea on that one ?

      Regards,

        • 1. Re: SelectOneMenu problem
          Francis LIMOUSY Newbie

          Ok,
          I replaced the s:selectItems by a good old fashioned f:selectItems backed to a List

           public List<SelectItem> getAssignableItems() {
           assignableItems = new ArrayList<SelectItem>();
          
           for(Assignable value : this.getAvailableLines())
           {
           String prefix = "";
           if(value instanceof Regie){
           prefix = "regie";
           }
           else if(value instanceof CollaborateurAffecte){
           prefix = "collaborateurAffecte";
           }
           else if(value instanceof CollaborateurAffecteAstreinte){
           prefix = "collaborateurAffecteAstreinte";
           }
           else if(value instanceof Conge){
           prefix = "conge";
           }
           else if(value instanceof OperationsDiverses){
           prefix = "operationsDiverses";
           }
          
           assignableItems.add( new SelectItem(prefix + "-" + value.getId(),value.getDesignation()));
           }
           return assignableItems;
           }
          

          As you can see, I'm converting manually in the getter.

          And it actually works !


          Well it works with f:selectItems and the s:selectItems code was working with seam 1.2 so I really guess there's a bug here but I'm not sure where I should debug to find it.

          Got an hint on this ?

          • 2. Re: SelectOneMenu problem
            Saeed Iqbal Novice

            i am having a similar problem.

            I think 2.0.1 has a fix for it.

            • 3. Re: SelectOneMenu problem
              Saeed Iqbal Novice

              I am wondering is this issue due to using jsf ri 1.2 compared to previously using myfaces? because our applications worked fine in 1.2 and now in 2.0 they are broke on SelectOneMenu :(