Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 11555 invoked from network); 18 Apr 2006 18:24:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 18 Apr 2006 18:24:29 -0000 Received: (qmail 3349 invoked by uid 500); 18 Apr 2006 18:24:19 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 3072 invoked by uid 500); 18 Apr 2006 18:24:18 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 3061 invoked by uid 99); 18 Apr 2006 18:24:18 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Apr 2006 11:24:18 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of flakie@gmail.com designates 64.233.182.188 as permitted sender) Received: from [64.233.182.188] (HELO nproxy.gmail.com) (64.233.182.188) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Apr 2006 11:24:17 -0700 Received: by nproxy.gmail.com with SMTP id p77so661682nfc for ; Tue, 18 Apr 2006 11:23:56 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Df+Pvv+/mBetK6vxx8W3uHN/kSgsoAGQmegurUHvdwDUijf6XVr1/rQh7v70h+s8IPfklwjVc1gW2AXbuRr8ddQCrTmVwnOGikEFapUETg8MVjdMxluFo1CuIy7LzbFYWnqNjfz9hanDLjoJoNr2qjaAZWsNKlMqXXYN4fHoRLM= Received: by 10.48.164.2 with SMTP id m2mr3533389nfe; Tue, 18 Apr 2006 11:23:56 -0700 (PDT) Received: by 10.48.161.7 with HTTP; Tue, 18 Apr 2006 11:23:56 -0700 (PDT) Message-ID: Date: Tue, 18 Apr 2006 13:23:56 -0500 From: "Eric Rank" To: "Struts Users Mailing List" Subject: Re: How to execute code in an Action when ActionForm validation fails? In-Reply-To: <583d4dff0604181059p551e4f84wdcc3736a11e4aaca@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <583d4dff0604181059p551e4f84wdcc3736a11e4aaca@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Thanks Rick, I agree that the manual validation approach is very good at keeping related code in one place. This is how I'm currently choosing to solve this problem. However, I feel that it's sloppy because it requires additional logic. I try to avoid using unecessary logic for the sake of keeping code readable. When I have a bunch of nested logic to sift through, it doesn't take more than 3 levels before I begin to lose my place in my own neural memory stack. Suddenly, 'execute' starts doing too much. In my mind, optionally implementing an interface / method designed to run when the form validation fails seems very elegant to me. The code is much more compartmentalized. Only, it doesn't work :-P That said, what you mention about being careful with the RequestProcessor is something I agree with. Thanks for your feedback! I'm curious about this chaining and interceptor business too. What's it all about? Eric Rank On 4/18/06, Rick Reumann wrote: > On 4/18/06, Eric Rank wrote: > > > From reading a bit on Rick Reumann's site > > (http://www.learntechnology.net/validate-manually.do) > > a simple way to handle this is to call the validate method within the > > execute method of the Action. There's a bit of logic that has to be > > processed in order to capture errors, but it works pretty well. > > However, I personally feel like it could lead to some sloppy "execute" > > code. > > Just curious what you think might be sloppy? One of struts biggest > weaknesses is in the validation side of things. I just happen to > prefer a consistent approach that is easy to understand, easy to > debug, and easy to code - hence I call validation manually from my > Action and don't ever use validate=3D"true" in my action mapping. > > Extending the request processor in my opinion is a bad idea. One of > the main reasons is it becomes very difficult for someone coming on to > your project to figure out what is going on, since it's not typical to > have to mess with that class. Obviously you have a lot of power if you > want to start messing with that class, but I avoid it. > > I haven't been following the latest Struts 1.3 stuff as closely as I'd > like so maybe someone else has some ideas that could help since I > think they've introduced more interceptor/chain types of things that > could aid in what you want. (Then again, I'm still not convinced all > this injection stuff is all it's cracked up to be. The trend seems to > be to make things so loosely coupled to the point that it's confusing > to often figure out 'what is causing' what to occur. It gets annoying > in my opinion to have to keep searching through different xml files to > figure out what is going on ). > > -- > Rick > http://www.learntechnology.net > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org