both ${} and %{} are supported in 2.1.x On Mon, Nov 2, 2009 at 11:10 AM, Greg Lindholm <greg.lindh...@gmail.com> wrote: > Here is the link [1] for "Parameters in configuration results", and yes it > is suppose to be ${} not %{} (but I thought it had been changed to support > %{}, hard to keep straight.) so you want to use 3a not 3b. > > You could show your getter, make sure it is public, returns a string and no > typos. > In the debugger you could break in prepare() make sure you are getting there > and also break in the getter to see if it is being called. > > You need to go back to result type of chain and in the debugger trace > through and find where your recursion is coming from. > > > > [1] > http://struts.apache.org/2.x/docs/parameters-in-configuration-results.html > > On Mon, Nov 2, 2009 at 1:40 PM, Siddiq Syed <siddiq...@yahoo.com> wrote: > >> >> 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. >> >> <action name="saveInitConsiderationEval" >> class="com.activity.EvaluateCaseAction" method="saveInitConsiderationEval"> >> <interceptor-ref name="redirectInput"/> >> <result name="success" type="redirect-action"> >> determineCaseEvaluationType >> </result> >> <result name="input" type="redirect-action"> >> determineCaseEvaluationTypeForInput >> </result> >> </action> >> <action name="determineCaseEvaluationTypeForInput" > >> <interceptor-ref name="redirectInput"/> >> <result name="input" type="tiles">${considTypeCode}</result> >> </action> >> >> 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 >> >> <action name="determineCaseEvaluationTypeForInput" > >> <interceptor-ref name="redirectInput"/> >> <result name="input" type="tiles">%{considTypeCode}</result> >> </action> >> >> 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 <siddiq...@yahoo.com> >> 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 >> >> >> >> <action name="saveInitConsiderationEval" >> >> class="com.activity.EvaluateCaseAction" >> >> method="saveInitConsiderationEval"> >> >> <interceptor-ref name="redirectInput"/> >> >> <result name="success" type="redirect-action"> >> >> determineCaseEvaluationType >> >> </result> >> >> <result name="input" type="chain"> >> >> determineCaseEvaluationTypeForInput >> >> </result> >> >> </action> >> >> >> >> 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: >> > >> > <result name="input" type="tiles"> %{myDestination} </result> >> > >> > 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. >> > >> > >> > >> > >> >> >> >> <action name="determineCaseEvaluationTypeForInput" >> >> class="com.activity.EvaluateCaseAction" >> >> method="determineCaseEvaluationTypeForInput"> >> >> <result name="guidelInitConsid" >> >> type="tiles">editGuidelinesCaseEvaluation</result> >> >> <result name="shrtsntcInitConsid" >> >> type="tiles">editShortSentenceCaseEvaluation</result> >> >> <result name="sscat2p1InitConsid" >> >> type="tiles">editShortSentenceCaseEvaluation</result> >> >> <result name="sscat2p2InitConsid" >> >> type="tiles">editShortSentenceCaseEvaluation</result> >> >> </action> >> >> >> >> <action name="determineCaseEvaluationType" >> >> class="com.activity.EvaluateCaseAction" >> >> method="determineCaseEvaluationType"> >> >> <result name="guidelInitConsid" >> >> type="tiles">editGuidelinesCaseEvaluation</result> >> >> <result name="shrtsntcInitConsid" >> >> type="tiles">editShortSentenceCaseEvaluation</result> >> >> <result name="sscat2p1InitConsid" >> >> type="tiles">editShortSentenceCaseEvaluation</result> >> >> <result name="sscat2p2InitConsid" >> >> type="tiles">editShortSentenceCaseEvaluation</result> >> >> >> >> </action> >> >> ---- 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 <siddiq...@yahoo.com> >> >> 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. >> >> >> >> >> >> <interceptors> >> >> >> <interceptor name="redirectMessage" >> >> >> class="com.interceptor.RedirectMessageInterceptor" /> >> >> >> <interceptor-stack name="redirectInput"> >> >> >> <interceptor-ref >> name="redirectMessage" >> >> /> >> >> >> <interceptor-ref >> >> >> name="paramsPrepareParamsStack" /> >> >> >> </interceptor-stack> >> >> >> </interceptors> >> >> >> I am iterating the session in the JSP and displaying the error >> >> messages.. >> >> >> >> >> >> <s:if test="#session.RedirectMessageInterceptor_FieldErrors != null"> >> >> >> <ul> >> >> >> <s:iterator value="#session.RedirectMessageInterceptor_FieldErrors" >> > >> >> >> <s:iterator id="id" value="value" > >> >> >> <li><s:property value="id" /></li> >> >> >> </s:iterator> >> >> >> </s:iterator> >> >> >> </ul> >> >> >> <% >> >> >> >> >> session.removeAttribute("RedirectMessageInterceptor_FieldErrors"); >> >> >> %> >> >> >> </s:if> >> >> >> >> >> >> 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-unsubscr...@struts.apache.org >> >> >> > For additional commands, e-mail: user-h...@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-unsubscr...@struts.apache.org >> >> >> For additional commands, e-mail: user-h...@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-unsubscr...@struts.apache.org >> >> For additional commands, e-mail: user-h...@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-unsubscr...@struts.apache.org >> For additional commands, e-mail: user-h...@struts.apache.org >> >> >
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org