This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSF and the fly likes validateLongRange in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "validateLongRange in JSF" Watch "validateLongRange in JSF" New topic
Author

validateLongRange in JSF

Minni Sharma
Greenhorn

Joined: Mar 03, 2010
Posts: 16
Hi All,
I am new to jsf and have following problem


<h:inputText size="10" id="mailboxesId1" value="#{faces$Mailboxes.mailBoxCounter}" >
<f:validateLongRange minimum="0"></f:validateLongRange>
</h:inputText>

If a long value is not given (a non long value is given ...like a alpha numeric value) the error message shows :
"mailboxesId1": Specified value is not a valid number

can I specify the text bos name rather than id anyways ? Please help

Regards
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

There's a "validatorMessage" attribute that you can place on the inputTextBox element to define a customized error message. The message will display exactly as coded, without that annoying ID in it.


Customer surveys are for companies who didn't pay proper attention to begin with.
Minni Sharma
Greenhorn

Joined: Mar 03, 2010
Posts: 16
Hi Tim,
thanks a lot for your reply,but I have a constraint of using JSF 1.1 and I think "validatorMessage" is added from JSF 1.2 onwards ....is there any other way of doing the same

Regards
Minni
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16019
    
  20

Minni Sharma wrote:Hi Tim,
thanks a lot for your reply,but I have a constraint of using JSF 1.1 and I think "validatorMessage" is added from JSF 1.2 onwards ....is there any other way of doing the same

Regards
Minni


It's probably easier just to switch to JSF 1.2. The differences aren't that great, other than the added improvements. Besides, JSF 1.1 is pretty old now.

About the closest workarounds I can think of are these:

1. Override the message on a global basis - but that doesn't allow you to tell people WHICH control is annoyed.

2. Write a custom validator that provides a custom message. Which is not a good long-term solution. Plus, attaching per-control messages is going to be a real pain, since custom validators don't take parameters. You'd either have to do nasty bits of internal magic or implement the validator as a full-blown custom tag.
Minni Sharma
Greenhorn

Joined: Mar 03, 2010
Posts: 16
Thanks Tim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: validateLongRange in JSF