Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JBoss User Help »

[jboss-user] [JBoss Seam] - s:selectItems changes in 2.0.0BETA1?

scott.stark@jboss.org

2007-07-06


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();
|    }
|  }
|

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4061427#4061427

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4061427
_______________________________________________
jboss-user mailing list
jboss-user@(protected)
https://lists.jboss.org/mailman/listinfo/jboss-user
©2008 junlu.com - Jax Systems, LLC, U.S.A.