[jboss-user] [JBoss Seam] - Backing a selectOneMenu with a Collection

fissy101 do-not-reply at jboss.com
Wed Jan 9 07:00:11 EST 2008


Hello,

I am trying to write a simple database application using seam. There are two entities, User and Movie. There is a ManyToOne relationship between them currently. From Movie.java:

  |     @ManyToOne
  |     public User getOwner() {return owner;}
  |     public void setOwner(User owner) {this.owner = owner;}
  | 
There is a movie.xhtml view which is used to create and edit Movie entities before persisting them. One of the required fields in this form is the owner of the Movie:

  | <h:selectOneMenu value="#{movie.owner}" required="true">
  |    <s:selectItems value="#{allusers}" var="user" label="#{user.firstName} #{user.familyName}" noSelectionLabel="Please Select..." cache="false"/>
  | </h:selectOneMenu>
  | 
The allusers Collection referred to here is a factory method defined in a UserList.java 'action' class:

  |     @Factory("allusers")
  |     public void findAllUsers() {
  |         System.out.println("findAllUsers called");
  |         allusers = em.createQuery("select u from User u").getResultList();
  |     }
  | 

When movie.xhtml is viewed, the selectOneMenu is populated with the firstName familyName, which is great. Unfortunately, when the form is submitted to create and persist the new Movie object, the following error is shown either in a big stack trace or just the facesMessages if I enable that in the page:

  |     *  /admin/movie.xhtml @31,57 value="#{movie.owner}": java.lang.IllegalArgumentException: argument type mismatch 
  | 
I don't really know where to start with this, as I don't know what is expecting an argument, or what what type it is expecting, or what I am sending it. Can anyone help?

Many thanks,
Dave

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

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



More information about the jboss-user mailing list