[jboss-user] [JBoss Seam] - Converter Issue

rvkishore do-not-reply at jboss.com
Thu Nov 29 11:45:31 EST 2007


I have two entities, Sheet and Category. A Sheet can belong to multiple Categories.

So, I have in my Sheet.java 


  | 
  |     @ManyToMany(mappedBy = "sheets")
  |     private List<Category> categories = new ArrayList<Category>();
  | 
  | 

In my create Sheet page 
  | 	                <h:outputText value="Category : " />
  | 					<h:selectManyListbox id="categoryList" value="#{sheet.categories}" required="true" converter="#{entityConverter}">
  | 						<s:selectItems value="#{categoryAction.rootCategories}" id="cats" var="cat" label="#{cat.name}(#{cat.id})" noSelectionLabel="Please Select..."/>
  |    					    <!-- <f:selectItems value="#{categoryAction.rootCategories}" />-->
  | 						<s:convertEntity/>
  | 					</h:selectManyListbox>
  | 

I am using the selectManyListBox to show the categories from which the user can choose while creating a new Sheet. I am getting the dreaded 
"value is not valid" exception.

The s:selectItems does not display the id value correctly in the list. It has a  positional index as the value for the list item which is not the id for the category object. So, I guess that is the reason why the converter is not able to get the Category object when submitted. So, I changed my xhtml page to the following


  | 
  | 	                <h:outputText value="Category : " />
  | 					<h:selectManyListbox id="categoryList" value="#{sheet.categories}" required="true" converter="#{entityConverter}">
  |    					    <f:selectItems value="#{categoryAction.rootCategories}" />
  | 						<s:convertEntity/>
  | 					</h:selectManyListbox>

Now, I am getting 
Argument Error: An option for component categoryList was not an instance of javax.faces.model.SelectItem. Type found: java.util.ArrayList.

My components.xml has the following for the converter

  |     <component name="entityConverter" scope="CONVERSATION" precedence="20"
  |                class="org.jboss.seam.ui.converter.EntityConverter">
  |         <property name="entityManager">#{entityManager}</property>
  |     </component>
  | 
Any ideas as to what I am doing wrong.

Thanks in advance

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

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



More information about the jboss-user mailing list