please help me to understand,
<h:form>
<h:panelGrid columns="3">
<h:outputText value="Age:"/>
<h:inputText value="#{userBean.age}" size="4"/>
<a4j:commandButton value="Enter Age" reRender="age"/>
</h:panelGrid>
<h:panelGrid>
<h:outputText id="age" value="Your age: #{userBean.age}"/>
</h:panelGrid>
</h:form>
when commandButton is clicked, how it evaluates a bean to call setters for. is it getting refrance from the bean used inside the input area?
thanks
The command button does not do that. The command button only determines for itself if an action has to be invoked and if so, which method it is. Each of the input components sets their own value. The actual job is done in the
decode()method of theRendererassociated with the component. During the apply request values phase, JSF walks through allUIForm,UIInputandUICommandcomponents. Each of them first gets the request parameter value by own client ID as request parameter name:(the
requestis hereHttpServletRequestandinputis hereUIInput)Then, after a process of conversion and validation where necessary, it get ultimately set as bean property referenced by its own
valueattribute.The
ValueExpression#setValue()will evaluate the#{userBean.age}, auto-create the bean if it doesn’t exist in the scope yet and then invoke thesetAge()method on it with the passed-in value.This is all in detail described in the JSF specification.