[jboss-user] [JBoss Seam] - Beginner: Bind SelectOneMenu to @onetoone entity object
Interista
do-not-reply at jboss.com
Sun Jan 20 17:15:56 EST 2008
Hi, I'm a newbie in jsf / seam and I think I have understand the basics, but now I have a question how to set a related object?
The case:
I have an entity Object, Category. The category has a OneToOne relation with another Category object, the parentCategory.
My entity has the @name("category") annotation.
The fields are mapped against this object, like:
<h:inputText value="#{category.categoryName}" />
<h:inputTextarea value="#{category.categoryDescription}">
I then want to choose the parent category from a select list, I have:
<h:selectOneMenu value="#{category.parentCategory}" converter="categoryConverter">
<f:selectItems value="#{categoryController.allCategoriesParentList}">
</f:selectItems>
</h:selectOneMenu>
I have a List returned from my controller object:
public List getAllCategoriesParentList() {
List list = new ArrayList();
int x = 0;
for(Category c : allCategories) {
System.out.println("Rendering " + c.getCategoryName());
list.add(new SelectItem(c.getId(), c.getCategoryName()));
}
return list;
}
So I set the list with the categorys names, but there is some things missing, which I cannot figure out how to implement. I guess I can inject the parentCategory object in some way so I dont have to load it from the persistence layer once again!?
Any help appriciated.
Thanks in advance
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4121676#4121676
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4121676
More information about the jboss-user
mailing list