The following facelet code, which renders a message when the employeeId inputText component loses focus, is executing successfully…
<h:inputText id="employeeId" value="#{questionAnswerAction.questionAnswerActionForm.employeeId}"
required="true" requiredMessage="#{app:requiredFieldMessage(bundle, 'label.peoplesoftId')}"
binding="#{questionAnswerAction.questionAnswerActionForm.employeeIdInputText}">
<f:ajax event="blur" render="employeeIdMessage" />
</h:inputText>
<h:message id="employeeIdMessage" errorClass="deg-msg-error" infoClass="deg-msg-info" for="employeeId"></h:message>
For some reason though, when I attempt to apply just about the same code on another facelet (the difference being that it is for a managerId instead of employeeId), when the setter occurs that gets triggered in the ajax call (setEmployeeId in the above call), my SessionScoped ManagedProperty is being flagged as null in the method. The ManagedProperty is actually a SessionScoped ManagedBean itself.
Can’t figure out why this code is working fine in one page but then in another facelet when the ‘set’ occurs the ManagedProperty is showing up as null…
The
bindingattribute causes problems when bound to a property of a bean in a scope broader than the request scope, such as the session scope, because you’re then basically sharing physically the same JSF component state across multiple page includes, page views and browser tabs/windows throughout the entire session. Get rid of it or rebind it to a request scoped bean.Just use a normal
ValidatororConverterdepending on the functional requirement and register it on the component. If you throw aValidatorExceptionorConverterException, then the wrappedFacesMessagewill automagically end up in the right place. This way you don’t need the component binding any more.This is answered by points 4 and 5 in commandButton/commandLink/ajax action/listener method not invoked or input value not updated.