Is validation firing at *all*? I had been under the impression that classes needed to be annotated with the "Validation" annotation.
http://struts.apache.org/2.x/docs/validation-annotation.html --- Eric D Nielsen <[EMAIL PROTECTED]> wrote: > I've been trying to figure out how to use Validation > Annotations with the > SmartURLs plugin. I'm not sure which half I'm not > understanding properly, but > I can't get the validations to fire at all. I've > seen several similiar posts > in the archives and have tried tweaking things in a > variety of directions. > I've also tried emulating Ted Husted's > Zero-Configuration Mail-Reader demo app. > > I've even tried adding what I think should be an > always failing > ExpressionValidator to help make sure that its not > some other subsystem > throwing off my expected results. > > The failure mode I'm seeing is that execure is > getting called regardless of the > validation success or failure. I'm adding my > action, struts.xml, > struts.properties, and web.xml. What am I missing > about how the validations > are supposed to work? > > Here's my action > ----------------- > package > com.ballroomregistrar.compinabox.web.action.account; > > import com.ballroomregistrar.compinabox.data.User; > import > com.ballroomregistrar.compinabox.data.service.UserDAO; > import > com.ballroomregistrar.compinabox.web.action.Unsecured; > import com.opensymphony.xwork2.ActionSupport; > import > com.opensymphony.xwork2.validator.annotations.EmailValidator; > import > com.opensymphony.xwork2.validator.annotations.ExpressionValidator; > import > com.opensymphony.xwork2.validator.annotations.RequiredStringValidator; > import > com.opensymphony.xwork2.validator.annotations.Validations; > > import org.texturemedia.smarturls.ActionName; > import org.texturemedia.smarturls.ActionNames; > import org.texturemedia.smarturls.Result; > > > @ActionNames({ > @ActionName(name="login", method="execute"), > @ActionName(name="login-input",method="input") > }) > @Result(name="success", > location="pendingActivation", > type="redirect-action") > @SuppressWarnings("serial") > @Unsecured > public class Create extends ActionSupport { > private String username; > private String email; > private String password; > private String password_confirm; > private UserDAO userDAO; > > > public String input() { > return INPUT; > } > > @Validations( > requiredStrings = { > > @RequiredStringValidator(fieldName="username",message="Please > enter a > username"), > > @RequiredStringValidator(fieldName="password",message="Please > enter a > password"), > > @RequiredStringValidator(fieldName="password_confim",message="Please > confirm your password")}, > emails = > [EMAIL PROTECTED](fieldName="email",message="Please > enter your e-mail > address")}, > expressions = { > > @ExpressionValidator(expression="password eq > password_confirm",message="The > two passwords must be the same"), > @ExpressionValidator(expression="true eq > false", message="Forcing > validation failed")} > ) > public String execute() { > User user = new User(); > user.setUsername(getUsername()); > user.setEmail(getEmail()); > user.setPassword(getPassword()); > userDAO.makePersistent(user); > return SUCCESS; > } > > public void setUsername(String username) { > this.username = username; > } > public String getUsername() { > return username; > } > > public void setEmail(String email) { > this.email = email; > } > public String getEmail() { > return email; > } > public void setPassword(String password) { > this.password = password; > } > public String getPassword() { > return password; > } > public void setPassword_confirm(String > password_confirm) { > this.password_confirm = password_confirm; > } > public String getPassword_confirm() { > return password_confirm; > } > public void setUserService(UserDAO service) { > userDAO=service; > } > public void setSubmit(String dummy) {} > > public static final String CANCEL = "cancel"; > > } > ------------------------- > My struts.xml > <?xml version="1.0" encoding="UTF-8" ?> > <!DOCTYPE struts PUBLIC > "-//Apache Software Foundation//DTD Struts > Configuration 2.0//EN" > "http://struts.apache.org/dtds/struts-2.0.dtd"> > <struts> > <constant name="struts.objectFactory" > value="spring" /> > <constant name="struts.devMode" value="true" /> > > <package name="cib-default" > extends="struts-default"> > <interceptors> > <interceptor name="authentication" > class="com.ballroomregistrar.compinabox.web.interceptors.AuthenticationInterceptor" > /> > <interceptor name="authorization" > class="com.ballroomregistrar.compinabox.web.interceptors.AuthorizationInterceptor" > /> > <interceptor-stack name="cibStack"> > <interceptor-ref name="authentication" /> > <interceptor-ref name="authorization" /> > <interceptor-ref name="defaultStack" /> > </interceptor-stack> > </interceptors> > <default-interceptor-ref name="cibStack" /> > <global-results> > <result name="login" > type="redirect">/login</result> > </global-results> > > </package> > > </struts> > > My struts.properties > > smarturls.action.packages=com.ballroomregistrar.compinabox.web.action > struts.action.extension= > smarturls.action.default.parent.package=cib-default > > My web.xml > > <?xml version="1.0" encoding="UTF-8"?> > > <web-app xmlns="http://java.sun.com/xml/ns/j2ee" > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee > > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" > version="2.4"> > > <display-name>CompInaBox</display-name> > <filter> > <filter-name>struts-cleanup</filter-name> > > <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class> > </filter> > === message truncated === --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]