Reputation: 23453
I have a custom validator on a JSF page and i am using view param to set the value of callbackUrl
intothe Backing Bean which is received in the URL.
For example,
http://localhost:8080/myapp/index.jsf?callbackUrl=google.com
The JSF:
<f:metadata>
<f:viewParam id="callbackUrl" name="callbackUrl"
value="#{userbean.callbackUrl}">
<f:validator validatorId="com.me.something.CallbackUrlValidator" />
</f:viewParam>
</f:metadata>
I have a custom validator that checks the URL whether this is valid. The custom validator executes once during page load and once during page submit. I would like only the validator to kick in only during page submit. Is there anyway i can do this?
Upvotes: 0
Views: 385
Reputation: 1109705
The <f:validator>
tag has a disabled
attribute for the very purpose.
To check whether the current request is a postback (a form submit), just check FacesContext#isPostback()
.
<f:validator ... disabled="#{not facesContext.postback}" />
Upvotes: 1