I tried to make a simple validation on a simple input text that passes the value to an integer .. added a validation message just to make sure the user does not insert a character .. added a custom validator message to tell the user "Please enter a digit". but the customized message never showed, instead I always go the default JSF validation message for an integer.
For this xhtml,
Here is the code that DID NOT work and I always got this error message:
My Managed Bean:
Here is the code that did work
Now I get the custom message I wanted.
For this xhtml,
<h:inputText value="#{reconciliations.amount}" validatorMessage="Please enter a valid digit number" class="defaultText" name="idType" id="amountTxt" > <f:validateRegex pattern="[0-9]*"></f:validateRegex> </h:inputText>
Here is the code that DID NOT work and I always got this error message:
viewReconciliation:amountTxt: 'a' must be a number between -2147483648 and 2147483647 Example: 9346
My Managed Bean:
private int amount; public int getAmount() { return amount; } public void setAmount(int amount) { this.amount = amount; }
Here is the code that did work
Now I get the custom message I wanted.
Please enter a valid digit numberMy Managed Bean:
private String amount; public String getAmount() { return amount; } public void setAmount(String amount) { this.amount = amount; }
No comments:
Post a Comment