I have defined flow:
Form Action with Validator:<view-state id="registrationForm">
<on-render>
<evaluate expression="registrationA.setupForm"/>
</on-render>
<transition on="potvrdit" to="registrationCheck">
<evaluate expression="registrationA.bindAndValidate"/>
</transition>
<transition on="zrusit" to="cancel"/>
</view-state>
Validator:<bean id="registrationA" class="org.springframework.webflow.action.FormActi on">
<property name="formObjectName" value="newUser"/>
<property name="formObjectClass" value="cz.sis.domain.User" />
<property name="validator" ref="userValidator"/>
<property name="formObjectScope" value="CONVERSATION"/>
<property name="formErrorsScope" value="CONVERSATION"/>
</bean>
The validator works well but I donīt know how to show error message in JSF view...I tried this:@Component("userValidator")
public class UserValidator implements Validator {
private RegistrationService registrationService;
@Override
public boolean supports(Class clazz) {
return User.class.equals(clazz);
}
@Override
public void validate(Object object, Errors errors) {
User user = (User) object;
if(registrationService.existUsername(user.getUsern ame())){
errors.rejectValue("username","errorCode","This username exists!");
}
}
public RegistrationService getRegistrationService() {
return registrationService;
}
@Autowired
public void setRegistrationService(RegistrationService registrationService) {
this.registrationService = registrationService;
}
}
But nothing was shown. Can you hel me please???<h:outputLabel for="username">#{resourceBundle.user_form_login}</h:outputLabel>
<sf:clientTextValidator required="true" regExp="^.{1,32}" invalidMessage="#{resourceBundle.user_form_login_r egexp}">
<h:inputText id="username" value="#{newUser.username}" />
</sf:clientTextValidator>
<h:message for="username" errorClass="errors"/>


Reply With Quote