Created
March 1, 2010 22:49
-
-
Save mojavelinux/318905 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h:form> | |
<f:event type="postValidate" listener="#{minMax.validate}"/> | |
<h:inputText id="min" value="#{bean.min}" | |
binding="#{minMax.minInput}"/> <h:message for="min"/> | |
<h:inputText id="max" value="#{bean.max}" | |
binding="#{minMax.maxInput}"/> <h:message for="max"/> | |
<h:commandButton value="Submit"/> | |
</h:form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public @Model class MinMax { | |
@Inject FacesContext ctx; | |
private UIInput minInput, maxInput; // accessors hidden | |
public void validate() { | |
if (ctx.isValidationFailed()) { return; } | |
if ((Integer) maxInput.getValue() < (Integer) minInput.getValue()) { | |
ctx.addMessage(maxInput.getClientId(ctx), | |
new FacesMessage("cannot be less than min value")); | |
ctx.validationFailed(); | |
ctx.renderResponse(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment