I'm not sure it's exactly what you're looking for, but IIRC there should be
a convention for the validate method, such that you can call, for example, a
method validateSave, expecting that it's fired contextually with the save
action

Maurizio Cucchiara

Il giorno 18/lug/2011 14.03, "Eric Lentz" <eric.le...@sherwin.com> ha
scritto:
I'm using the wildcard method in my configuration

   <action name="foo-*" class="FooAction" method="{1}">
     <result name="success">pages/foo.jsp</result> ...

and I want validation to fire only upon the call to the method that
performs the save/update. No problem with the XML file as the name takes
care of that (e.g., assuming "save" is the method name:
FooAction-foo-save-validation.xml).

What about when I use the validate() method? Is there a
standard/convention for that? I did the following, but I'm wondering if
that is the "best" way.

       String invokingMethod =
ActionContext.getContext().getActionInvocation().getProxy().getMethod();
       if (invokingMethod.equals("save")) {
         // Do validation
       }

That solution adds more framework into my action class which I'm not wild
about, but I already have interfaces and I'm extending ActionSupport, so
adding one more thing... okay I guess?

I realize I could validate inside my "save" method, but again, I'm
wondering what the /best/ approach is (i.e., standard/convention).

- Eric

Reply via email to