struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <newton.d...@yahoo.com>
Subject Re: Action Validator ans <s:url...
Date Fri, 06 Apr 2007 01:38:34 GMT
--- stanlick@gmail.com wrote:
> Actually annotations do work at the method level.

That's what I thought too :/ I must be doing something
toopid, and I would have sworn I did this before (but
I already made one huge mis-assumption about my
validations); hopefully it'll be obvious to a fresh
set of eyes.

-- struts.xml

<struts>
  <constant
name="struts.enable.DynamicMethodInvocation"
value="true" />
  <constant name="struts.devMode" value="true" />
  <include file="/val1/val1-struts.xml"/>
</struts>

-- /val1/val1-struts.xml

<struts>
  <package name="val1" namespace="/val1"
extends="struts-default">
    <action name="val1" class="val1.Val1Action">
      <result
name="input">/WEB-INF/jsp/val1/val1.jsp</result>
    </action>
    
    <action name="val2" class="val1.Val1Action">
      <result
name="input">/WEB-INF/jsp/val1/val2.jsp</result>
    </action>
  </package>
</struts>

-- Val1Action (minus fname/lname get/setters)

@Validation()
public class Val1Action extends ActionSupport {
    
    @Validations(
        requiredStrings = {
           
@RequiredStringValidator(type=ValidatorType.SIMPLE,
fieldName="fname", message="First name required")
        }
    )
    public String req1() throws Exception {
        return INPUT;
    }

    @Validations(
        requiredStrings = {
           
@RequiredStringValidator(type=ValidatorType.SIMPLE,
fieldName="lname", message="Last name required")      
 
        }
    )
    public String req2() throws Exception {
        return INPUT;
    }
}

-- val1.jsp

<s:form action="val1!req1" method="post">
  <s:textfield name="fname" label="First Name"/>
  <s:textfield name="lname" label="Last Name"/>
  <s:submit/>
</s:form>
    
-- val2.jsp

<s:form action="val2!req2" method="post">
  <s:textfield name="fname" label="First Name"/>
  <s:textfield name="lname" label="Last Name"/>
  <s:submit/>
</s:form>

I always seem to be getting both validation errors
with several combinations of dynamic method invocation
vs. config file method attributes etc.

(I also can't figure out why I can't set the
validateAnnotatedMethodOnly attribute of either the
XWork ValidationInterceptor or S2
AnnotationValidationInterceptor, but that's a
different issue.)

d.



 
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check. 
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html 

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


Mime
View raw message