8 Replies Latest reply on Jul 10, 2007 5:40 PM by jimk1723

    s:selectItems changes in 2.0.0BETA1?

    jimk1723

      It looks like there were some changes to s:selectItems that broke functionality that worked in Seam 1.2.

      I had a panel that displayed two selectManyListboxes for adding and removing things from an entity - one box displayed the list of available items, the other displayed the list of assigned items. In Seam 1.2 this worked, after the update to 2.0.0 it appears that the listbox backed by the entity query is only updated during the Process Validations phase (or Apply Request Values if I set immediate = true.)

      The net effect is that the list of "available" things doesn't reflect the state of the entity since it was updated before the action handler.

      What should I change so that #{bucketHome.availableThings} is updated *after* the event actions are executed - so the result list doesn't include the Things that were just added or removed?

      Here's my relevant JSF:

       <s:decorate id="assignThings" template="layout/edit.xhtml">
       <ui:define name="label">Assign Things!</ui:define>
       <table>
       <thead>
       <tr>
       <th>Available Things</th>
       <th> </th>
       <th>Assigned Things</th>
       </tr>
       </thead>
       <tbody>
       <tr>
       <td>
       <h:selectManyListbox id="things1" value="#{bucketHome.thingsToAdd}" size="10">
       <s:selectItems var="thing" value="#{bucketHome.availableThings}" label="#{thing.name}" />
       <s:convertEntity />
       </h:selectManyListbox>
       </td>
       <td>
       <div>
       <h:commandButton value=">" action="#{bucketHome.addThings}" />
       </div>
       <div>
       <h:commandButton value="<" action="#{bucketHome.removeThings}" />
       </div>
       </td>
       <td>
       <h:selectManyListbox id="things2" value="#{bucketHome.thingsToRemove}" size="10">
       <s:selectItems var="thing" value="#{bucketHome.instance.things}" label="#{thing.name}" />
       <s:convertEntity />
       </h:selectManyListbox>
       </td>
       </tr>
       </tbody>
       </table>
       </s:decorate>
      



      The logic is all in the EntityHome:


       List<Thing> thingsToAdd;
      
       List<Thing> thingsToRemove;
      
       public void addThings() {
       for (Thing thing : thingsToAdd) {
       getInstance().getThings().add(thing);
       }
       }
      
       public void removeThings() {
       for (Thing thing : thingsToAdd) {
       getInstance().getThings().remove(thing);
       }
       }
      
       public List<Thing> getThingsToAdd() {
       return thingsToAdd;
       }
      
       public void setThingsToAdd(List<Thing> thingsToAdd) {
       this.thingsToAdd = thingsToAdd;
       }
      
       public List<Thing> getThingsToRemove() {
       return thingsToRemove;
       }
      
       public void setThingsToRemove(List<Thing> thingsToRemove) {
       this.thingsToRemove = thingsToRemove;
       }
      
       public List getAvailableThings() {
      
       if (getInstance() != null && getInstance().getThings() != null
       && getInstance().getThings().size() > 0) {
       return getEntityManager()
       .createQuery(
       "SELECT thing FROM Thing thing WHERE thing NOT IN (:things)")
       .setParameter("things", getInstance().getThings())
       .getResultList();
       } else {
       return getEntityManager().createQuery(
       "SELECT thing FROM Thing thing").getResultList();
       }
       }
      


        • 1. Re: s:selectItems changes in 2.0.0BETA1?
          jimk1723

          Ok, I tested this out on Seam 1.2 under JBoss 4.0.5 and Seam 2.0.0BETA1 under JBoss 4.2. It's the same code with two different behaviors.

          Would it be easier to ask if there are any working examples of the type of UI I'm trying to implement? I checked the Booking, DVD Store and Seam UI examples, but no luck.

          • 2. Re: s:selectItems changes in 2.0.0BETA1?
            pmuir

            It sounds like a reasonable use case, but I'm not aware of it in an example - I want to rework the UI example, and I'll see if I can get something like this in. I'm not sure what your problem is exactly as I don't quite understand your explanation. If you post a step by step list for what is happening, and a step by step list for what should happen I'll look again (and I got very confused as to which listbox was which in the above expln).

            • 3. Re: s:selectItems changes in 2.0.0BETA1?
              harpritt

              That is some VERY cool stuff! especially the

              <framework:entity-query name="continents" ejbql="select c from Continent c" />

              in components.xml

              • 4. Re: s:selectItems changes in 2.0.0BETA1?
                harpritt

                ..... sorry i seem to have posted on the wrong board

                • 5. Re: s:selectItems changes in 2.0.0BETA1?
                  jimk1723

                   

                  "pete.muir@jboss.org" wrote:
                  It sounds like a reasonable use case, but I'm not aware of it in an example - I want to rework the UI example, and I'll see if I can get something like this in. I'm not sure what your problem is exactly as I don't quite understand your explanation.


                  Here's an example of my UI working under Seam 1.2:

                  http://video.google.com/videoplay?docid=-2142860533872781220&hl=en

                  The quality is miserable, but you can clearly see that selecting items from the left list and clicking the command button moves the items to the other list.

                  Here are the logs from the "add" request - note that getAvailableThings is called during Process Validations and Render Response.

                  15:04:07,895 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW(1)
                  15:04:07,895 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW(1)
                  15:04:07,911 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW(1)
                  15:04:07,927 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW(1)
                  15:04:07,942 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE APPLY_REQUEST_VALUES(2)
                  15:04:07,942 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE APPLY_REQUEST_VALUES(2)
                  15:04:07,958 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER APPLY_REQUEST_VALUES(2)
                  15:04:07,958 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER APPLY_REQUEST_VALUES(2)
                  15:04:07,958 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE PROCESS_VALIDATIONS(3)
                  15:04:07,958 ERROR [STDERR] Jul 9, 2007 3:04:07 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE PROCESS_VALIDATIONS(3)
                  15:04:07,989 INFO [BucketHome] in getAvailableThings
                  15:04:07,989 INFO [STDOUT] Hibernate: select thing0_.id as id11_, thing0_.name as name11_, thing0_.version as version11_ from test.Thing thing0_
                  15:04:08,005 INFO [BucketHome] in getThingsToAdd
                  15:04:08,020 INFO [BucketHome] in getThingsToRemove
                  15:04:08,083 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER PROCESS_VALIDATIONS(3)
                  15:04:08,083 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER PROCESS_VALIDATIONS(3)
                  15:04:08,083 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE UPDATE_MODEL_VALUES(4)
                  15:04:08,099 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE UPDATE_MODEL_VALUES(4)
                  15:04:08,099 INFO [BucketHome] in setThingsToAdd
                  15:04:08,114 INFO [BucketHome] in setThingsToRemove
                  15:04:08,130 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER UPDATE_MODEL_VALUES(4)
                  15:04:08,130 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER UPDATE_MODEL_VALUES(4)
                  15:04:08,130 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE INVOKE_APPLICATION(5)
                  15:04:08,130 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE INVOKE_APPLICATION(5)
                  15:04:08,130 INFO [BucketHome] in addThings
                  15:04:08,145 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER INVOKE_APPLICATION(5)
                  15:04:08,145 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER INVOKE_APPLICATION(5)
                  15:04:08,145 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE(6)
                  15:04:08,161 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE(6)
                  15:04:08,208 INFO [BucketHome] in getAvailableThings
                  15:04:08,208 INFO [STDOUT] Hibernate: select thing0_.id as id11_, thing0_.name as name11_, thing0_.version as version11_ from test.Thing thing0_ where thing0_.id not in (? , ?)
                  15:04:08,224 INFO [BucketHome] in getThingsToAdd
                  15:04:08,239 INFO [BucketHome] in getThingsToRemove
                  15:04:08,349 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE(6)
                  15:04:08,364 ERROR [STDERR] Jul 9, 2007 3:04:08 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE(6)
                  



                  Here is an example of the same code running under Seam 2.0.0BETA - note how after the postback the left hand list still contains the old items.

                  http://video.google.com/videoplay?docid=-4098366542019750853&hl=en



                  And again, here are the logs - getAvailableThings is not called during render response so the left hand listbox still reflects the state of the UI as it was before the Invoke Application.

                  15:24:50,113 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RESTORE_VIEW 1
                  15:24:50,113 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RESTORE_VIEW 1
                  15:24:50,145 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE APPLY_REQUEST_VALUES 2
                  15:24:50,176 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER APPLY_REQUEST_VALUES 2
                  15:24:50,176 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE PROCESS_VALIDATIONS 3
                  15:24:50,238 INFO [BucketHome] in getAvailableThings
                  15:24:50,238 INFO [STDOUT] Hibernate: select thing0_.id as id53_, thing0_.name as name53_, thing0_.version as version53_ from test.Thing thing0_
                  15:24:50,254 INFO [BucketHome] in getThingsToAdd
                  15:24:50,270 INFO [BucketHome] in getThingsToRemove
                  15:24:50,363 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER PROCESS_VALIDATIONS 3
                  15:24:50,379 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE UPDATE_MODEL_VALUES 4
                  15:24:50,395 INFO [BucketHome] in setThingsToAdd
                  15:24:50,410 INFO [BucketHome] in setThingsToRemove
                  15:24:50,442 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER UPDATE_MODEL_VALUES 4
                  15:24:50,457 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE INVOKE_APPLICATION 5
                  15:24:50,457 INFO [BucketHome] in addThings
                  15:24:50,457 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER INVOKE_APPLICATION 5
                  15:24:50,473 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker beforePhase
                  INFO: BEFORE RENDER_RESPONSE 6
                  15:24:50,660 INFO [BucketHome] in getThingsToAdd
                  15:24:50,676 INFO [BucketHome] in getThingsToAdd
                  15:24:50,691 INFO [BucketHome] in getThingsToAdd
                  15:24:50,707 INFO [BucketHome] in getThingsToRemove
                  15:24:50,723 INFO [BucketHome] in getThingsToRemove
                  15:24:50,863 ERROR [STDERR] Jul 9, 2007 3:24:50 PM org.exadel.jsf.PhaseTracker afterPhase
                  INFO: AFTER RENDER_RESPONSE 6
                  


                  • 6. Re: s:selectItems changes in 2.0.0BETA1?
                    pmuir

                    ROTFL - I've never had a video posted to look at before! Nice idea ;)

                    Hmm, can you try with CVS. I did fix a bug recently that might be responsible for this.

                    If not, can you stick a breakpoint on getValue in org.jboss.seam.ui.component.UISelectItems and see *why* it's not refreshing the value.

                    • 7. Re: s:selectItems changes in 2.0.0BETA1?
                      jimk1723

                       

                      "pete.muir@jboss.org" wrote:
                      ROTFL - I've never had a video posted to look at before! Nice idea ;)


                      That's a shame indeed - it's all about CamStudio: http://www.camstudio.org/

                      "pete.muir@jboss.org" wrote:

                      Hmm, can you try with CVS. I did fix a bug recently that might be responsible for this.


                      Will do.

                      • 8. Re: s:selectItems changes in 2.0.0BETA1?
                        jimk1723

                        I checked out the HEAD - whatever magic is in CVS fixed it.