Problem with h:selectOneMenu and rendered attribute
knuffi Feb 15, 2009 5:18 AMHello,
I'm stuck with a problem regarding Hibernate persistance and facelets. In my view I want to display a selectOneMenu depending on the request param sent, therefore I have used the rendered attribute. But through this rendered attribute, it seems, that properties on the BackBean are not properly set, thus resulting in a not-null property results to null for ...
in the persist action.
View:
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" template="layout/template.xhtml"> <ui:define name="body"> <h:form id="person_facultyForm"> <rich:panel> <f:facet name="header">employment</f:facet> <s:decorate id="PersonField" template="layout/edit.xhtml"> <ui:define name="label">Person</ui:define> <h:selectOneMenu rendered="#{not empty personHome.person_id}" value="#{person_facultyHome.instance.person}" required="true"> <f:selectItem itemValue="#{personHome.instance}" itemLabel="#{personHome.instance.name}, #{personHome.instance.firstname}"/> </h:selectOneMenu> </s:decorate> . . . <div class="actionButtons"> <h:commandButton id="save" value="Save" action="#{person_facultyHome.persist}" rendered="#{!person_facultyHome.managed}"/> <s:button propagation="end" id="cancel" value="Done" view="/employment.xhtml"> </s:button> </div> </h:form> ...
person_facultyHome.instance.person results to null(but still rendered correctly) in persist action, if rendered attribute is used. If this rendered attribute is not used everything is fine.
personHome:
@Name("personHome") public class PersonHome extends EntityHome<Person> { @RequestParameter Integer person_id; @Override public Object getId() { if (person_id == null) { return super.getId(); } else { return person_id; } } @Override @Begin(join=true) public void create() { super.create(); } public Integer getPerson_id() { return person_id; } public void setPerson_id(Integer person_id) { this.person_id = person_id; } }
person_facultyHome
@Name("person_einrichtungHome") public class Person_EinrichtungHome extends EntityHome<Person_Einrichtung> { @RequestParameter Integer pe_id; @Override public Object getId() { if (pe_id == null) { return super.getId(); } else { return pe_id; } } @Override @Begin(join=true) public void create() { super.create(); } public Integer getPe_id() { return pe_id; } public void setPe_id(Integer pe_id) { this.pe_id = pe_id; } }
I really do not understand why it's behaving like that, and especially not Seam and JSF lifecycles. I am still very new to Seam and JSF. Help very appreciated. I'm very frustrated :). Thank you in advance.