We also have a pattern for many situations where we encapsulate our page-centric handling into a single action where for example a GET into the action sets up the page, and a POST to the same action for form handling but to a different method in the action. Our approach to avoid validation on the Get is that we have taken to writing most of our validation as java code in the validate() method of an action that implements validation aware, and have gotten away from plugging in validators to objects for this particular reason. So what we do is:
public void validate() { String actionMethod = ActionContext.getContext().getActionInvocation().getProxy().getMethod(); if (actionMethod.equals("myActionMethodConfiguredAsTheFormPostTarget")) { // do some validation } } This also allows us to delegate validation to other classes needed to handle more complex validation scenarios. -----Original Message----- From: benjamin haimerl [mailto:b-ski...@gmx.de] Sent: Thursday, March 26, 2009 1:34 PM To: Struts Users Mailing List Subject: Re: How to avoid validation if request was done by GET method? hi boraldo a very simple way should be: Action: YourActionConnetedToTheFormAction extends Action..{ execute(..){ String qString = request.getQueryString(); if(qString!=null && paramsFound(...)) // *paramsFound() = check if your formParams were given by query String } else { //check if your formBean is set (depends on the scope you have set in your struts-config.xml) //e.g. if(request.getAttribute(yourForm)!=null) { yourForm.validate() { } } } } should work ;) boraldo wrote: > I have a form. And I want to have one url for form itself and for submitting > it. > Controller should look at method and if it is GET, show form, if POST - make > validations and so on. > > How can I do it ? > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org