[jboss-user] [JBoss Seam] - Re: Using <s:selectItems> with a list of entities

pgmjsd do-not-reply at jboss.com
Wed Feb 28 16:21:05 EST 2007


Here's the view code:
 
  |            <h:selectOneMenu id="theSelect" value="#{myBean.selectedUser}">
  |                 <s:selectItems value="#{myBean.users}" var="user"
  |                                noSelectionLabel="Select a user..." label="#{user.name}"/>
  |                 <ec:convertEntity/>
  |             </h:selectOneMenu>
  | 

Here's the SLSB:
@Name("myBean")
  | @Stateful
  | @Logging
  | public class TestBean implements TestLocal
  | {
  |     @PersistenceContext
  |     private EntityManager em;
  | 
  |     private List<User> users;
  | 
  |     private User selectedUser;
  | 
  |     public List<User> getUsers()
  |     {
  |         if (users == null)
  |         {
  |             Query q = em.createQuery("select t from User t join t.roles r where r = :role");
  |             q.setParameter("role", Role.SPECIAL_ROLE);
  |             //noinspection unchecked
  |             users = q.getResultList();
  |         }
  |         return users;
  |     }
  | 
  |     public User getSelectedUser()
  |     {
  |         return selectedUser;
  |     }
  | 
  |     public void setSelectedUser(User selectedUser)
  |     {
  |         this.selectedUser = selectedUser;
  |     }    
  |     @Destroy
  |     @Remove
  |     public void destroy()
  |     {
  |     }
  | }
  | 

I'm using Seam 1.1.6 and EntityConverter 0.1.

The problem happens when rendering the <h:selectOneMenu> for the first time.  I can see with the debugger that the ConverterChain has two converters in it: the NoSelectionConverter and the EntityConverter.  The EntityConverter never get's called for the list of Users when rendering.


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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4023971



More information about the jboss-user mailing list