RE: Conditional fire on validation()
Hello Eric, Another way of doing this would be using aliases. In other words the validation.xml file follows the action name not the class. If you send save action "foo-save" and method "save" pages/foo.jsp You create one declarative validation file per call So you add a validation file per possible action foo-save.xml foo-delete.xml etc why not check : http://struts.apache.org/2.x/docs/validation.html#Validation-HowValidato rsofanActionareFound http://struts.apache.org/2.x/docs/validation.html#Validation-DefiningVal idationRules -Original Message- From: Eric Lentz [mailto:eric.le...@sherwin.com] Sent: lundi 18 juillet 2011 14:16 To: Struts Users Mailing List Subject: Re: Conditional fire on validation() > 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 Oh yeah! I remember coming across that now. Post 40 with all these frameworks I have stuffed in my head... thanks for the reminder. - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org
Re: Conditional fire on validation()
> 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 Oh yeah! I remember coming across that now. Post 40 with all these frameworks I have stuffed in my head... thanks for the reminder.
Re: Conditional fire on validation()
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" ha scritto: I'm using the wildcard method in my configuration pages/foo.jsp ... 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