Hello,
This is my first post and i want to thank all developers of AppFuse for
their effort. It's great soft. It helps me to speed up my learnig path of
developing web application with Spring and Hibernate.
I'm creating a simple work tracking system for my company and have a problem
i'm stucked with.
I have a UserActvity bean in my model where I store a duration time (Integer
durationTime) of user activity in minutes.
On my User Activity form i wanted to show/edit this property in time format
'hh:mm' so I created TimePropertyEditor which extends PropertyEditorSupport
(with setAsText and getAsText methods).
I wanted also a validator which validates if there is a proper format and (0
<= hh <= 23) and (0 <= mm <= 59).
In this purpose i created a 'time' validator in validator-rules-custom.xml
and add validateTime function to ValidationUtil.java
public static boolean validateTime(Object bean, ValidatorAction va,
Field field, Errors errors) {
String value = ValidatorUtils.getValueAsString(bean,
field.getProperty());
if (!GenericValidator.isBlankOrNull(value)) {
try {
if(!value.matches("(([0-9])|([0-1][0-9])|([2][0-3])):(([0-9])|([0-5][0-9]))"))
{
FieldChecks.rejectValue(errors, field,
va);
return false;
}
} catch (Exception e) {
FieldChecks.rejectValue(errors, field, va);
return false;
}
}
return true;
}
Almost everything works greate with JavaScript support. I got proper
messages in the browser generated by JavaScript. The problem is when the
form is sent to server and validateTime is called.
On the form i have the time in format 'hh:mm' but the UserActivity bean
stors this as an Integer so
String value = ValidatorUtils.getValueAsString(bean, field.getProperty());
gets the Integer bean value transformed by setAsText of the
PropertyEditorSupport (not the value from the form in the hh:mm format).
Now, my question is if there is a possibility to get posted value (not the
value from the bean) from the form in the validateTime method?
Maybe there is another solution?
Best Regards
Jarek
--
View this message in context:
http://www.nabble.com/Property-editor-support-and-validator-rules-conflict-tf2972467s2369.html#a8317709
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]