Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 36130 invoked from network); 2 Nov 2009 18:41:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Nov 2009 18:41:06 -0000 Received: (qmail 66923 invoked by uid 500); 2 Nov 2009 18:41:03 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 66848 invoked by uid 500); 2 Nov 2009 18:41:03 -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 66838 invoked by uid 99); 2 Nov 2009 18:41:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Nov 2009 18:41:03 +0000 X-ASF-Spam-Status: No, hits=-0.3 required=5.0 tests=BAYES_00,FORGED_YAHOO_RCVD X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Nov 2009 18:41:00 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1N51pX-0001qS-Ay for user@struts.apache.org; Mon, 02 Nov 2009 10:40:39 -0800 Message-ID: <26157771.post@talk.nabble.com> Date: Mon, 2 Nov 2009 10:40:39 -0800 (PST) From: Siddiq Syed To: user@struts.apache.org Subject: Re: Preserving Messages and Garbage values Across a Redirect in Struts 2 In-Reply-To: <74a2042d0910301523n5f325a5hd181e1e384dd24f7@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: siddiq_sa@yahoo.com References: <26114968.post@talk.nabble.com> <74a2042d0910290831w119db28bne8805f7cdb0f00a5@mail.gmail.com> <26119066.post@talk.nabble.com> <74a2042d0910291236v29d04e3fl9d7264c59e678ee8@mail.gmail.com> <26119902.post@talk.nabble.com> <74a2042d0910300542p644381cbkc3d6e633ccf2ab4a@mail.gmail.com> <26131518.post@talk.nabble.com> <26132363.post@talk.nabble.com> <74a2042d0910301013o752702f4s423777b51195ce54@mail.gmail.com> <4AEB24E8.5060500@newfield.org> <26134455.post@talk.nabble.com> <74a2042d0910301227u22482c68n4bf417b40036dc9d@mail.gmail.com> <26136963.post@talk.nabble.com> <74a2042d0910301523n5f325a5hd181e1e384dd24f7@mail.gmail.com> Hi Greg, Creating a variable in the action , seems not working. Here are the steps that i have done. step 1. Create a variable considTypeCode in the action , and so is getter ,setter. step 2. Create a prepare() method in the action, which sets the value of the considTypeCode to determine what will be the next page to display if validation fails. step 3. a) specify ${} in struts.xml file as show below. determineCaseEvaluationType determineCaseEvaluationTypeForInput ${considTypeCode} In this case it is throwing the below mention exception javax.servlet.ServletException: org.apache.tiles.definition.NoSuchDefinitionException: b) specify %{} in strust.xml file as show below %{considTypeCode} In this case it is throwing the below mention exception javax.servlet.ServletException: org.apache.tiles.definition.NoSuchDefinitionException:%{considTypeCode} In the debug mode , I can see the values of the considTypeCode and even I kept a hidden variable in the JSP that can assign the value again, I donno where the value is missing. If I keep type="chain" then an recursion excpetion is throw. Caused by: Infinite recursion detected: [/rating/saveInitConsiderationEval!saveInitConsiderationEval, /rating/determineCaseEvaluationTypeForInput, /rating/determineCaseEvaluationTypeForInput] - [unknown location] Any idea where I might have went wrong ? Thanks Siddiq. Greg Lindholm-2 wrote: > > On Fri, Oct 30, 2009 at 5:15 PM, Siddiq Syed wrote: > >> >> First off all Thank you so much Greg, You have been doing a great job!. >> And >> you express things pretty clear, Which I may not. >> Please bare with me for some more time. >> >> When I am doing a chain in the input, as show below >> >> > class="com.activity.EvaluateCaseAction" >> method="saveInitConsiderationEval"> >> >> >> determineCaseEvaluationType >> >> >> determineCaseEvaluationTypeForInput >> >> >> >> The action "determineCaseEvaluationTypeForInput" is again looking for the >> input, in which case there is no input. >> > > Yes I see there is no 'input' and this is the problem. > > The way the struts validation framework works is the validators set error > messages if a validation fails and then the workflow interceptor checks to > see if there are any errors and sets the result to 'input' if there are > errors. > > So this is what is happening when you chain to action > determineCaseEvaluationTypeForInput, you have errors so workflow is > returning 'input', and this will happen before so your action method will > never be called. > > This is how the validation framework works, if you want to use it you must > supply 'input' result for any action that may have errors. > > One thing that may work for you is you don't have to hardcode the result > destination you can use and expression like this: > > %{myDestination} > > and have your action supply a getMyDestination() method. > > but remember your action execute method will not be called so you would > have > to do all your logic in either prepare() or prepareInput() methods. > > If you can't do this then I don't see how you can use the struts > validation > framework, you would have to manage errors yourself and remove the > workflow > interceptor from your stack. > > > > >> >> > class="com.activity.EvaluateCaseAction" >> method="determineCaseEvaluationTypeForInput"> >> > type="tiles">editGuidelinesCaseEvaluation >> > type="tiles">editShortSentenceCaseEvaluation >> > type="tiles">editShortSentenceCaseEvaluation >> > type="tiles">editShortSentenceCaseEvaluation >> >> >> > class="com.activity.EvaluateCaseAction" >> method="determineCaseEvaluationType"> >> > type="tiles">editGuidelinesCaseEvaluation >> > type="tiles">editShortSentenceCaseEvaluation >> > type="tiles">editShortSentenceCaseEvaluation >> > type="tiles">editShortSentenceCaseEvaluation >> >> >> ---- The question is pretty simple and in a simple view. >> >> I am displaying the JSP depend on the some string that action returns, >> When >> validation happens(fails) I want to display the same jsp with the >> validation >> message and the values. >> >> I hope you got my last sentece. I got an alternate for this by setting >> the >> request value in the getter and setter method of the view bean which is a >> bad approach , I know !! -:( >> >> >> Thanks >> Siddiq. >> >> Greg Lindholm-2 wrote: >> > >> > 1) Your interceptor stack is fine. >> > >> > 2) Dale was simply pointing out a very common newbie mistake; when you >> > specify an interceptor-ref in an action it will replace (not append) >> the >> > interceptor stack. Since you hadn't shown what redirectInput was it was >> a >> > possible source of error. Now you have shown it, we can see it is OK. >> > (see >> > #1) >> > >> > 3) Result type of Chain is still probably the answer for you. You say >> it >> > didn't work but don't describe what that means and what exactly you >> tried. >> > (see note below) >> > >> > 4) You should not need to iterate over >> > #session.RedirectMessageInterceptor_FieldErrors to get the errors from >> the >> > RedirectMessageInterceptor. This is not the way it is meant to be >> used, >> > it's suppose to handle the messages automatically, that's the whole >> point >> > of >> > it. >> > >> > In order for RedirectMessageInterceptor to work properly you need to >> > always >> > include it in your interceptor stack on both the actions that generate >> the >> > messages and on the actions that get redirected to. This is explained >> in >> > the doc and comments for RedirectMessageInterceptor. >> > >> > Note that the action that you redirect to, following a validation >> error, >> > will always use the 'input' result since the presents of the error >> > messages >> > will cause the workflow interceptor to return a result of 'input'. You >> > might want to read this over a couple times to make sure you get it. >> The >> > action you redirect to will return a result of 'input' because the >> > workflow >> > interceptor sees that there are errors. (Maybe this is why you though >> > chain >> > wasn't working). >> > >> > You seem to have such an unusual configuration that you may have to >> > develop >> > your own solutions since the standard ones don't seem to work for you. >> As >> > I >> > explained earlier, doing a redirect following a validation error is >> almost >> > always the wrong thing to do and the standard approach is to dispatch >> back >> > to the input page. >> > >> > >> > On Fri, Oct 30, 2009 at 1:57 PM, Siddiq Syed >> wrote: >> > >> >> >> >> The interceptor mention is nothing but >> >> RedirectMessageInterceptor( >> >> http://glindholm.wordpress.com/category/struts-2/) >> >> and I specified that in the strust.xml, >> >> This interceptor is to preserve the error messages. >> >> >> >> >> >> > >> class="com.interceptor.RedirectMessageInterceptor" /> >> >> >> >> > /> >> >> > >> name="paramsPrepareParamsStack" /> >> >> >> >> >> >> I am iterating the session in the JSP and displaying the error >> messages.. >> >> >> >> >> >>
    >> >> >> >> >> >>
  • >> >>
    >> >>
    >> >>
>> >> <% >> >> >> session.removeAttribute("RedirectMessageInterceptor_FieldErrors"); >> >> %> >> >>
>> >> >> >> As I said my first attempt was to use Chain , but It was not working. >> >> And I don't understand what Dale is saying , can you elaborate please. >> >> >> >> Dale -- you mean to say chain and interceptor doesnot go together. !! >> -:( >> >> >> >> >> >> Thanks >> >> Siddiq. >> >> >> >> >> >> DNewfield wrote: >> >> > >> >> > Greg Lindholm wrote: >> >> >> The only other thing is your interceptor stack 'redirectInput' you >> >> >> haven't >> >> >> shown what it is. >> >> > >> >> > And note--specifying any interceptor(s) in the action causes the >> >> > specified interceptor(s) to be the only ones used. >> >> > >> >> > -Dale >> >> > >> >> > >> --------------------------------------------------------------------- >> >> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> >> > For additional commands, e-mail: user-help@struts.apache.org >> >> > >> >> > >> >> > >> >> >> >> -- >> >> View this message in context: >> >> >> http://old.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26134455.html >> >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> >> For additional commands, e-mail: user-help@struts.apache.org >> >> >> >> >> > >> > >> >> -- >> View this message in context: >> http://old.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26136963.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org >> For additional commands, e-mail: user-help@struts.apache.org >> >> > > :confused: -- View this message in context: http://old.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26157771.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org