Search code examples
jsflifecycle

JSF 1.1: question about lifecycles, why the rendering attribute influences the managed bean action below?


I have a page "start.jsf" which points to an action #{ruler.start}, this action forwards the request to "flow.jsf".

The managed bean "ruler" (request scoped) contains some properties, one of them called "ruler.operation", correctly filled into "start.jsf".

The page "flow.jsf" has a command button pointing to an another managed bean called "objectList" (session scoped) containing a property object named "objectList.selectedContractor" (a POJO initialized into the constructor, so its children properties are always empty only at the first MB call, or wrong?), its action is #{objectList.itemInsert}.

The form page of "flow.jsf" contains the following tags:

 <h:form>
 <h:inputText id="crnameNew" value="#{objectList.selectedContractor.crname}" rendered="#{ruler.operation eq ruler.codeOperationNew}" />

 <h:inputText id="someProp" value="#{objectList.someProp}" />
 <h:commandButton styleClass="importedButton" value="insert" action="#{objectList.itemInsert}" />
 </h:form>

Well, when I submit the action #{objectList.itemInsert}, only "someProp" is correctly filled into the MB, while "selectedContractor.crname" results empty.

BUT if I toggle the "rendered" attribute from the tag binding the #{objectList.selectedContractor.crname}, it works and fill correctly when #{objectList.itemInsert} is invoked... so why "rendered" affect the processing of a submission?


Solution

  • As the attribute suggests it only affects the rendering. If it's rendered on the page then the value will be sent back to the Bean on form submission. If it's rendering and this isn't happening then something else is wrong.