I hate it when I do this kind of thing. My input result was pointing to
the wrong result.  Me <-- My own worst enemy. 

-----Original Message-----
From: Griffith, Michael * [mailto:michael.griff...@fda.hhs.gov] 
Sent: Wednesday, February 04, 2009 11:13 AM
To: Struts Users Mailing List
Subject: Why is Validation not firing?

Hello all, 
 
I must be missing something subtle about my configuration. I'm using
Struts 2.0.11 and want to use annotation based validation, but can't
seem to get it working.
 
My action class has an update method as such:
@Validation
public class ArtifactAction extends BaseAction implements
                ModelDriven<Artifact>, Preparable, ServletRequestAware {

        ...

        @Validations( visitorFields = {...@visitorfieldvalidator(message =
"Validation Error", fieldName = "model", appendPrefix = false)})
        public String update() throws Exception {
                artifactService.saveArtifact(artifact);
                return SUCCESS;
        }
}

The model class is marked as such:

@Entity
@Table(name = "ART", schema = "x")
@Validation
public class Artifact implements Identifiable, java.io.Serializable {

        ...
        @Lob
        @Column(name = "DESCRIPTION", nullable = false)
        @RequiredStringValidator(message="Validation
Error",key="validate.notEmpty", trim=true) 
        public String getDescription() {
                return this.description;
        }

}

And my struts.xml is configured to use an interceptor stack that should
include validations:
           <interceptors>
            <interceptor
class="...web.struts.interceptor.AcegiInterceptor" name="acegi"/>
            <interceptor-stack name="authenticated">
                <interceptor-ref name="acegi"/>
                <interceptor-ref name="paramsPrepareParamsStack">
                        <param
name="validation.validateAnnotatedMethodOnly">true</param>
                </interceptor-ref>
            </interceptor-stack>
        </interceptors>
        <default-interceptor-ref name="authenticated"/>

When I submit the form:

                <s:form action="update" namespace="/component"
method="post">
                        <s:hidden name="id" />
                    <s:textarea key="component.description"
name="description" required="true" />
                    <s:if test="id < 1">
                                <s:submit key="button.create" />
                    </s:if>
                    <s:else>
                                <s:submit key="button.update" />
                    </s:else>
                </s:form>

No validations fire. The update action does have an input result
defined.  What am I missing?


Any help would be appreciated!

MG

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to