Hi guys,
anything (technically) against using a form backing object and it's validator in one bean? Like this:
It seems to work and i like to use it that way caus it's basically a complete UI Form represented as a Java object.Code:public class RequestPasswordHintForm implements Validator { private String email; private String username; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } // ~ Validation ------------------------------------------------------------ public boolean supports(Class clazz) { return RequestPasswordHintForm.class.isAssignableFrom(clazz); } public void validate(Object command, Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "email", "ume.ui.err.requiredEmail", null); // more basic validation } }
Wiring looks like that:
Any technical objections? The same class would exist as a singleton in the bean framework and as objects factored in controller:formBackingObjcet(); Could it cause problems? Someone used it already? I'm grateful for any input.Code:<bean id="/self-service-request-hint" class="com.thyrell.cdb.ui.web.ume.RequestPasswordHintController"> <property name="selfService" ref="spring:comp/env/ume/CustomerSelfService"/> <property name="formView" value="/self-service-request-hint"/> <property name="successView" value="/self-service-request-hint-sent"/> <property name="validator"> <bean class="com.thyrell.cdb.ui.web.ume.RequestPasswordHintForm"/> </property> </bean>
Best,
Andi


Reply With Quote