[jboss-user] [JBoss Seam] - <s:selectItems noSelectionLabel=
pgmjsd
do-not-reply at jboss.com
Thu Mar 1 12:41:43 EST 2007
I'm using Seam 1.1.6, myfaces 1.1.4, EntityConverter 0.1 from the wiki page. The Seam managed EntityManagerFactory is set up correctly.
Here's the problem: When noSelectionLabel is specified UISelectItems ends up using NoSelectionConverter for all the User objects in the list instead of using EntityConverter. When the form is posted, the values for the select are the 'toString()' of the User entity, which EntityConverter doesn't understand.
Anyone else have this problem? Is it fixed in 1.2? Should I even bother with noSelectionLabel and EntityConverter?
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 SSB:
| @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()
| {
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024384#4024384
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4024384
More information about the jboss-user
mailing list