okey, ho sotto mano il codice in questione, ve lo posto:
estratto delle parte inerenti di struts-config.xml:
codice:
<!--definizione del form bean->
<form-bean name="FirstRegistrationFormBean" type="validation.FirstRegistrationForm"/>
<!--definizione della action->
<action name="FirstRegistrationFormBean" path="/FirstRegistration" scope="request" type="strutsAction.registration.FirstRegistration" input="/Composition/FirstRegistration.jsp" validate="true">
<forward name="success" path="/ok.htm"/>
<forward name="error" path="/err.htm"/>
</action>
metodo validate della classe validation.FirstRegistrationForm
codice:
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request){
ActionErrors err = new ActionErrors();
//validazione
if(email==null || email.equals("")){
err.add("email", new ActionMessage("error.FirstRegistration.emailRequired"));
}
if(emailConf==null || emailConf.equals("")){
err.add("emailConf", new ActionMessage("error.FirstRegistration.emailConfRequired"));
}
if(!emailConf.equals(email)){
err.add("emailConf", new ActionMessage("error.FirstRegistration.emailConfNotMatching"));
}
if(password==null || password.length()<6){
err.add("password", new ActionMessage("error.FirstRegistration.passwordLength"));
}
if(passwordConf==null || !passwordConf.equals(password)){
err.add("passwordConf", new ActionMessage("error.FirstRegistration.passwordConfNotMatching"));
}
if(firstname==null || firstname.equals("")){
err.add("firstname", new ActionMessage("error.FirstRegistration.firstnameRequired"));
}
if(lastname==null || lastname.equals("")){
err.add("lastname", new ActionMessage("error.FirstRegistration.lastnameRequired"));
}
return err;
}
codice di FirstRegistration.jsp
codice:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<head>
<title>test</title>
</head>
<body>
<h1 align='center'>Registration-2</h1>
<html:form action="/FirstRegistration.do" method="post"><html:errors/>
Type your email here: <html:text property="email"/>
Retype the email: <html:text property="emailConf"/>
Password (at least 6 characters): <html:password property="password"/>
Retype your password: <html:password property="passwordConf"/>
Firstname: <html:text property="firstname"/>
Middlename (not required): <html:text property="middlename"/>
Lastname: <html:text property="lastname"/>
<html:submit>Register</html:submit>
</html:form>
</body>
</html>
spero che possiate aiutarmi!
Ciao