I have a listener that listens for JSF validation failures, and I need to be able to turn off a specific piece of functionality depending on certain contexts.
In my listener I only have the SystemEvent, so this listener isn't component specific, I was wondering if there was any way to pass around any other information, perhaps something like attributes on the FacesContext?...so that later in the validation listener I could check the context for an attribute that I could set in the JSF.
Ie
<f:someContextParam name="turnOff" value="true"/>
then later
boolean turnOff = (Boolean) FacesContext.getCurrentInstance().someWayToGetAttribute("turnOff");
...seems like a shot in the dark, I'm just trying to see if theres any contextual way to pass back information before I rewrite the architecture.
You could enclose a
<f:attribute>
tag inside your input component and then retrieve the attribute value inside the validator viaFacesContext.getCurrentInstance().getAttributes().get(attrname);
Syntax for the tag should be
<f:attribute name="attrname" value="#{ELexpr}">
Here's a semi complete example validator:
and corresponding jsf
Updated Fixed the wrong use of the context to get the attribute to get it from the component instead.