I'm trying to get struts to spit out the client side validation code and it
doesn't seem to be working. The backend validation is working fine but when
I use the xhtml theme with the <s:head />, the script code under the form is
not being generated.
Looking at the code it looks like it's failing this check
"parameters.performValidation?default(false) == true" in the
form-close-validate.ftl file. What would cause the performValidation not to
be set as true?
I'm using annotations to markup my action.
public class TestAction extends ActionSupport {
private String username, email, password, password2;
@Override
public String execute() {
return SUCCESS;
}
public String save() {
// Do stuff and return SUCCESS ...
}
@RequiredStringValidator(message = "Required Field.", key =
"validation.required")
@EmailValidator(message = "Enter a valid email.", key =
"validation.email")
public String getEmail() {
return email;
}
@RequiredStringValidator(message = "Required Field.", key =
"validation.required")
@StringLengthFieldValidator(trim = true, minLength = "3" , maxLength =
"16",
message = "Must be between ${minLength} and
${maxLength}.", key =
"validation.length")
public String getPassword() {
return password;
}
@FieldExpressionValidator(expression = "password2.equals(password)",
message = "Passwords do not match.", key =
"validation.match.passwords")
@RequiredStringValidator(message = "Required Field.", key =
"validation.required")
public String getPassword2() {
return password2;
}
@RequiredStringValidator(message = "Required Field.", key =
"validation.required")
@StringLengthFieldValidator(trim = true, minLength = "3" , maxLength =
"16",
message = "Must be between ${minLength} and
${maxLength}.", key =
"validation.length")
public String getUsername() {
return username;
}
public void setEmail(final String email) {
this.email = email;
}
public void setPassword(final String password) {
this.password = password;
}
public void setPassword2(final String password2) {
this.password2 = password2;
}
public void setUsername(final String username) {
this.username = username;
}
}
here is my form code:
<s:form label="Test Form" id="save3" action="save" namespace="/install"
validate="true" theme="xhtml" cssClass="form-large">
<s:textfield key="username" required="true" theme="xhtml" />
<s:textfield key="email" required="true" theme="xhtml" />
<s:password key="password" required="true" theme="xhtml" />
<s:password key="password2" required="true" theme="xhtml"/>
<s:submit key="save" theme="xhtml" />
</s:form>
struts.xml
<!-- Constant Settings -->
<constant name="struts.enable.DynamicMethodInvocation" value="false" />
<constant name="struts.codebehind.pathPrefix" value="/WEB-INF/pages/"/>
<constant name="struts.url.includeParams" value="none" />
<constant name="struts.custom.i18n.resources" value="global-messages" />
<constant name="struts.objectFactory" value="guice" />
<constant name="guice.module" value="test.util.ConfigurationModule" />
<!-- Development Settings "Change these when going to production" -->
<constant name="struts.devMode" value="true" />
<constant name="struts.i18n.reload" value="true" />
<constant name="struts.configuration.xml.reload" value="true" />
<package name="test" namespace="/install" extends="struts-default">
<action name="index" class="test.action.TestAction">
<result>/WEB-INF/pages/index.jsp</result>
</action>
<action name="save" class="test.action.TestAction"
method="save">
<result
name="success">/WEB-INF/pages/success.jsp</result>
<result name="input">/WEB-INF/pages/index.jsp</result>
<result
name="error">/WEB-INF/pages/error/default.jsp</result>
</action>
</package>
--
View this message in context:
http://www.nabble.com/Struts-2.1.2-client-side-validation-doesn%27t-get-generated-tp20221161p20221161.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]