aspose file tools*
The moose likes JSF and the fly likes Hour check in an inputText Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Hour check in an inputText" Watch "Hour check in an inputText" New topic
Author

Hour check in an inputText

Alessio Belcastro
Greenhorn

Joined: Nov 09, 2011
Posts: 8
Hi everybody,
I have an inputText where the user must insert an hour in the format HH:mm (so with the hours within 00 and 23, not AM-PM). I've tried two ways to check what the user enters:
1) Using convertDateTime:

It works for the checks on the hour, but the value of "time" (which is defined by me as a String type) in the bean is not saved as HH:mm but as a full datetime, like "Monday, May 14, 2007 2:39:56 PM" (I've also tried using timeStyle="short" instead of defining the pattern)
2) a Javascript control. The check works, if you type the hour in a wrong way you get an "error" alert, but then the page sends you to another page as specified in the commandLink action, as if the control hadn't been elaborated (as if the JSF part has an "higher priority" compared to Javascript)

I'm italian and I've started using JSF a week ago so I'm not very skilled about that...please, answer in a simple wayyy! Thank you
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16142
    
  21

Welcome to the JavaRanch, Alessio! Benvenuto!

You will have better fortune, I think if you make the "export.time" property be a java.util.Date object instead of a string. This will require some back-end Calendar logic to get/set the String version of the date, but it will interact better with the JSF date formatting and conversion functions.


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

Joined: Nov 09, 2011
Posts: 8
Thank you for your welcome! Grazie
Oooh, I didn't think about that! I've tried right now and it's working perfectly! I just had to convert to and by string as you said and to put the "HH:mm" pattern in the outputTexts to make it show just the hour and it's correct now! Thank you so much for your help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hour check in an inputText