in my web app I can’t get the key values of query parameters with a single validator.
My webpage:
<f:metadata>
<f:viewParam name="version" value="#{myBean.version}"
validator="#{myBean.inputValidator}" />
<f:viewParam name="mobilemodel" value="#{myBean.mobileModel}"
validator="#{myBean.inputValidator}" />
<f:event listener="#{myBean.preRenderViewEventHandler}"
type="preRenderView" />
</f:metadata>
My function to validate components:
public void inputValidator(FacesContext context, UIComponent component, Object value) throws ValidatorException {
LOG.debug("Component: " + component);
LOG.debug("Value: " + value);
}
I can’t find the key value (ex. version) in the UIComponent
A solution that works fine is to have one Validator function for each query parameter. There is a way to understand the name of the parameter?
Next question: it’s possible to skip all Validators and set value to myBean? I tried, but the values was not setted in myBean.mobileModel
You can get all component attributes by
UIComponent#getAttributes().So, just this should do: