[jboss-user] [JBoss Seam] - Re: How to use si:selectItems with an object that has a Stri

lawrieg do-not-reply at jboss.com
Thu Feb 1 06:47:52 EST 2007

I've done some more investigating and the problem is that the <h:selectOneMenu> value property (which is #{customerHome.instance.customerType}) is passed to the BasicEntityConverter, and that customerHome.instance.customerType holds a new instance of CustomerType which doesn't have any fields set.

The issue seems to stem from the seam-gen generated entity home code:

  | public class CustomerHome extends EntityHome<Customer> {
  | 	@In(value = "#{customerTypeHome.instance}", required = false)
  | 	CustomerType customerType;
  | 	@In(value = "#{refCustomerStatusHome.instance}", required = false)
  | 	RefCustomerStatus refCustomerStatus;
  | 	public void setCustomerId(Integer id) {
  | 		setId(id);
  | 	}
  | 	public Integer getCustomerId() {
  | 		return (Integer) getId();
  | 	}
  | 	@Override
  | 	protected Customer createInstance() {
  | 		Customer result = new Customer();
  | 		result.setCustomerType(customerType);
  | 		result.setRefCustomerStatus(refCustomerStatus);
  | 		return result;
  | 	}
  | 	public List<Activity> getActivities() {
  | 		return getInstance() == null ? null : new ArrayList<Activity>(
  | 				getInstance().getActivities());
  | 	}
  | }

Do I need to change the seam-gen generated code (i.e. is it incorrect)? (I presume I do if the BasicEntityConverter doesn't convert a null id to whatever is required for the "no item selected" item in the drop down list to be selected.

What value for #{customerHome.instance.customerType} in (<h:selectOneMenu> value property) would cause my drop down to correctly have the "Please Select..." (no item selected) item selected when the page is displayed? Should my CustomerHome createInstance() method   instead be setting the customerType to null rather than #{customerTypeHome.instance}???

Any help would be really appreciated as I'm struggling to get my code working with <h:selectOneMenu> & <si:selectItems> and none of the examples are really helping to clarify things...

Thanks in advance,


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

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

More information about the jboss-user mailing list