|
View:
New views
19 Messages
—
Rating Filter:
Alert me
|
|
|
Preserving Messages and Garbage values Across a Redirect in Struts 2Hi all,
I have been using Glindholm's RedirectMessageInterceptor to perserve the validations/error messages and is working absoulty fine. But the problem is the values in the fields are not stored. If a form has 10 fields of which 2 fields are not valid(It does not pass validation), Intercerptor displays the error message but doesnot shows the values in the fields of the form. I hope you guys got the problem. I don't want the user to enter all the values every time even if the validation fails for 1 or 2 field. Please let me know if you have occured this problem and have the solution for the same. Thanks in advance. http://glindholm.wordpress.com/ Thanks Siddiq. |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2The short answer is don't redirect when validation fails.
For results of "input" you should not be doing a redirect or you get the problem you described. On Thu, Oct 29, 2009 at 11:13 AM, Siddiq Syed <siddiq_sa@...> wrote: > > Hi all, > > I have been using Glindholm's RedirectMessageInterceptor to perserve the > validations/error messages and is working absoulty fine. > > But the problem is the values in the fields are not stored. > > If a form has 10 fields of which 2 fields are not valid(It does not pass > validation), Intercerptor displays the error message but doesnot shows the > values in the fields of the form. > > I hope you guys got the problem. I don't want the user to enter all the > values every time even if the validation fails for 1 or 2 field. > > Please let me know if you have occured this problem and have the solution > for the same. > > Thanks in advance. > > http://glindholm.wordpress.com/ > > > Thanks > Siddiq. > -- > View this message in context: > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26114968.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2Hi Greg,
Thanks for your quick repley,! The reason for doing a redirect on the input is that system needs to determine what will be the page to display next along with the error messages and the garbage values. As a temporary solution i am using the getter and setter methods of the variables of View bean ,storing the request values in a temporary session and retriving it in the redirect method of action. and setting back in the request. -:) which i Guess in not a good approach. But i Guess there should be some way other than the above. Thanks Siddiq.
![]() |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2Still don't understand why you need to redirect on input result.
Normally when validation fails you want to return the user back to the same page. If you dispatch back to the input jsp page (instead of redirect) then all the input parameters will be there so can be redisplayed with the error messages. <result name="input">/myInputPage.jsp</result> Maybe if you posted your struts config and gave a more detailed explanation someone could help you with a better solution. On Thu, Oct 29, 2009 at 3:13 PM, Siddiq Syed <siddiq_sa@...> wrote: > > Hi Greg, > > Thanks for your quick repley,! > > The reason for doing a redirect on the input is that system needs to > determine what will be the page to display next along with the error > messages and the garbage values. > > As a temporary solution i am using the getter and setter methods of the > variables of View bean ,storing the request values in a temporary session > and retriving it in the redirect method of action. and setting back in the > request. -:) which i Guess in not a good approach. > > But i Guess there should be some way other than the above. > > > Thanks > Siddiq. > > > Greg Lindholm-2 wrote: > > > > The short answer is don't redirect when validation fails. > > > > For results of "input" you should not be doing a redirect or you get the > > problem you described. > > > > On Thu, Oct 29, 2009 at 11:13 AM, Siddiq Syed <siddiq_sa@...> > wrote: > > > >> > >> Hi all, > >> > >> I have been using Glindholm's RedirectMessageInterceptor to perserve > the > >> validations/error messages and is working absoulty fine. > >> > >> But the problem is the values in the fields are not stored. > >> > >> If a form has 10 fields of which 2 fields are not valid(It does not pass > >> validation), Intercerptor displays the error message but doesnot shows > >> the > >> values in the fields of the form. > >> > >> I hope you guys got the problem. I don't want the user to enter all the > >> values every time even if the validation fails for 1 or 2 field. > >> > >> Please let me know if you have occured this problem and have the > solution > >> for the same. > >> > >> Thanks in advance. > >> > >> http://glindholm.wordpress.com/ > >> > >> > >> Thanks > >> Siddiq. > >> -- > >> View this message in context: > >> > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26114968.html > >> Sent from the Struts - User mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscribe@... > >> For additional commands, e-mail: user-help@... > >> > >> > > > > > :-(( > -- > View this message in context: > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26119066.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2I donno If i can able to explain it to you, I will try my best , here is the secinario
Step 1. When the user click the button on the page, depend on the string return from the action method the page will be display and is configured in the struts.xml file as mention below. <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> </action> step 2. There are fields in the pages like 10 text boxes 2 drop down and 2 radio buttons , when I fill all the field and click submit it will do the neccessary business operation and return the string to which page is to display, and is mention in the struts.xml file as mention 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> step 3. : when valiations fails I need to determine on which page validations failed and hence I am forwarding the the input to method which it will determine what page to be displayed. <action name="determineCaseEvaluationTypeForInput" class="us.ga.state.pap.cons.clemency.presentation.action.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> </action> I hope you got the sicenario , Its tofugh to explain whatz going on in the mind ! Thanks Siddiq.
|
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2Ok, I think I understand. The key point seems to be that on a validation
fail you need to execute another action. <result name="input" type="redirect-action"> determineCaseEvaluationTypeForInput </result> You might want to try a Chain result [1] and action chaining [2]. I know there are warnings about action chaining but this may be a good use of it. [1] http://struts.apache.org/2.x/docs/chain-result.html [2] http://struts.apache.org/2.x/docs/action-chaining.html On Thu, Oct 29, 2009 at 4:13 PM, Siddiq Syed <siddiq_sa@...> wrote: > > I donno If i can able to explain it to you, I will try my best , here is > the > secinario > > > Step 1. When the user click the button on the page, depend on the string > return from the action method the page will be display and is configured in > the struts.xml file as mention below. > > <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> > </action> > > step 2. There are fields in the pages like 10 text boxes 2 drop down and 2 > radio buttons , when I fill all the field and click submit it will do the > neccessary business operation and return the string to which page is to > display, and is mention in the struts.xml file as mention 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> > > step 3. : when valiations fails I need to determine on which page > validations failed and hence I am forwarding the the input to method which > it will determine what page to be displayed. > > <action name="determineCaseEvaluationTypeForInput" > > class="us.ga.state.pap.cons.clemency.presentation.action.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> > </action> > > I hope you got the sicenario , Its tofugh to explain whatz going on in the > mind ! > > Thanks > Siddiq. > > > Greg Lindholm-2 wrote: > > > > Still don't understand why you need to redirect on input result. > > > > Normally when validation fails you want to return the user back to the > > same > > page. If you dispatch back to the input jsp page (instead of redirect) > > then > > all the input parameters will be there so can be redisplayed with the > > error > > messages. > > > > <result name="input">/myInputPage.jsp</result> > > > > Maybe if you posted your struts config and gave a more detailed > > explanation > > someone could help you with a better solution. > > > > > > On Thu, Oct 29, 2009 at 3:13 PM, Siddiq Syed <siddiq_sa@...> > wrote: > > > >> > >> Hi Greg, > >> > >> Thanks for your quick repley,! > >> > >> The reason for doing a redirect on the input is that system needs to > >> determine what will be the page to display next along with the error > >> messages and the garbage values. > >> > >> As a temporary solution i am using the getter and setter methods of the > >> variables of View bean ,storing the request values in a temporary > >> session > >> and retriving it in the redirect method of action. and setting back in > >> the > >> request. -:) which i Guess in not a good approach. > >> > >> But i Guess there should be some way other than the above. > >> > >> > >> Thanks > >> Siddiq. > >> > >> > >> Greg Lindholm-2 wrote: > >> > > >> > The short answer is don't redirect when validation fails. > >> > > >> > For results of "input" you should not be doing a redirect or you get > >> the > >> > problem you described. > >> > > >> > On Thu, Oct 29, 2009 at 11:13 AM, Siddiq Syed <siddiq_sa@...> > >> wrote: > >> > > >> >> > >> >> Hi all, > >> >> > >> >> I have been using Glindholm's RedirectMessageInterceptor to perserve > >> the > >> >> validations/error messages and is working absoulty fine. > >> >> > >> >> But the problem is the values in the fields are not stored. > >> >> > >> >> If a form has 10 fields of which 2 fields are not valid(It does not > >> pass > >> >> validation), Intercerptor displays the error message but doesnot > shows > >> >> the > >> >> values in the fields of the form. > >> >> > >> >> I hope you guys got the problem. I don't want the user to enter all > >> the > >> >> values every time even if the validation fails for 1 or 2 field. > >> >> > >> >> Please let me know if you have occured this problem and have the > >> solution > >> >> for the same. > >> >> > >> >> Thanks in advance. > >> >> > >> >> http://glindholm.wordpress.com/ > >> >> > >> >> > >> >> Thanks > >> >> Siddiq. > >> >> -- > >> >> View this message in context: > >> >> > >> > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26114968.html > >> >> Sent from the Struts - User mailing list archive at Nabble.com. > >> >> > >> >> > >> >> --------------------------------------------------------------------- > >> >> To unsubscribe, e-mail: user-unsubscribe@... > >> >> For additional commands, e-mail: user-help@... > >> >> > >> >> > >> > > >> > > >> :-(( > >> -- > >> View this message in context: > >> > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26119066.html > >> Sent from the Struts - User mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscribe@... > >> For additional commands, e-mail: user-help@... > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26119902.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2Hi Greg,
Thank for your input, But i tried this at my first attempt, Its not working with this sicenario. The problem is that you need to define two different actions one is on success and one is on input. If input is defined it will exceute irrespecitve of what returns from the action. <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> I am thinking of capturing request object(HttpRequest) in the interceptor itself, and get the object from the request and set in the session, so that the request values can be retrived again from the sessin in the action. But I am not getting the desired object in the request. Here it is what I am trying to do in the RedirectMessageInterceptor.java, In doIntercept method i am trying to get the request. HttpServletRequest req = ServletActionContext.getRequest(); public String doIntercept(ActionInvocation invocation) Any idea why I am not gettting the desired object from the request in Interceptor.? I guess the flow goes like this , once you hit the submit button --> getter,setter methods will be invoked ---- interceptor -- sturs.xml -- action.java ! Hope you are not confusing with this. Thanks Siddiq.
|
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2Here is the general understanding of the result types.
redirect-action -- uses the new request object. dispatcher --- Dispacther uses the old request object but the location must be a view not an action. Chain --- chain uses the old request object but it is excuted irrespective of what returns from the action success or input, even if the validation pass chain is going to exucute. redirect -- same as redirect-action. There should be a result-type which uses the same old request object and can be redirect to an action or do we need to create one !! Thanks, Siddiq.
![]() ![]() |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2I don't think you understanding of Chain result type is correct. The
type="chain" is part of the result type, it wont effect other results, each result is configured independently. You should be able to configure a chain result for just result of 'input' like this: <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 only other thing is your interceptor stack 'redirectInput' you haven't shown what it is. On Fri, Oct 30, 2009 at 11:47 AM, Siddiq Syed <siddiq_sa@...> wrote: > > Here is the general understanding of the result types. > > > redirect-action -- uses the new request object. > dispatcher --- Dispacther uses the old request object but the location must > be a view not an action. > Chain --- chain uses the old request object but it is excuted irrespective > of what returns from the action success or input, even if the validation > pass chain is going to exucute. > redirect -- same as redirect-action. > > There should be a result-type which uses the same old request object and > can > be redirect to an action or do we need to create one !! > > Thanks, > Siddiq. > > > Siddiq Syed wrote: > > > > Hi Greg, > > > > Thank for your input, But i tried this at my first attempt, Its not > > working with this sicenario. > > > > > > The problem is that you need to define two different actions one is on > > success and one is on input. > > > > If input is defined it will exceute irrespecitve of what returns from the > > action. > > > > <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> > > > > > > I am thinking of capturing request object(HttpRequest) in the interceptor > > itself, and get the object from the request and set in the session, so > > that the request values can be retrived again from the sessin in the > > action. > > > > But I am not getting the desired object in the request. > > > > Here it is what I am trying to do in the RedirectMessageInterceptor.java, > > In doIntercept method i am trying to get the request. > > > > HttpServletRequest req = ServletActionContext.getRequest(); > > > > public String doIntercept(ActionInvocation invocation) > > > > Any idea why I am not gettting the desired object from the request in > > Interceptor.? > > > > I guess the flow goes like this , once you hit the submit button --> > > getter,setter methods will be invoked ---- interceptor -- sturs.xml -- > > action.java ! > > > > Hope you are not confusing with this. > > > > > > Thanks > > Siddiq. > > > > > > Greg Lindholm-2 wrote: > >> > >> Ok, I think I understand. The key point seems to be that on a > validation > >> fail you need to execute another action. > >> > >> <result name="input" type="redirect-action"> > >> determineCaseEvaluationTypeForInput > >> </result> > >> > >> You might want to try a Chain result [1] and action chaining [2]. I > know > >> there are warnings about action chaining but this may be a good use of > >> it. > >> > >> [1] http://struts.apache.org/2.x/docs/chain-result.html > >> [2] http://struts.apache.org/2.x/docs/action-chaining.html > >> > >> > >> > >> On Thu, Oct 29, 2009 at 4:13 PM, Siddiq Syed <siddiq_sa@...> > wrote: > >> > >>> > >>> I donno If i can able to explain it to you, I will try my best , here > >>> is > >>> the > >>> secinario > >>> > >>> > >>> Step 1. When the user click the button on the page, depend on the > >>> string > >>> return from the action method the page will be display and is > configured > >>> in > >>> the struts.xml file as mention below. > >>> > >>> <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> > >>> </action> > >>> > >>> step 2. There are fields in the pages like 10 text boxes 2 drop down > and > >>> 2 > >>> radio buttons , when I fill all the field and click submit it will do > >>> the > >>> neccessary business operation and return the string to which page is to > >>> display, and is mention in the struts.xml file as mention 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> > >>> > >>> step 3. : when valiations fails I need to determine on which page > >>> validations failed and hence I am forwarding the the input to method > >>> which > >>> it will determine what page to be displayed. > >>> > >>> <action name="determineCaseEvaluationTypeForInput" > >>> > >>> > class="us.ga.state.pap.cons.clemency.presentation.action.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> > >>> </action> > >>> > >>> I hope you got the sicenario , Its tofugh to explain whatz going on in > >>> the > >>> mind ! > >>> > >>> Thanks > >>> Siddiq. > >>> > >>> > >>> Greg Lindholm-2 wrote: > >>> > > >>> > Still don't understand why you need to redirect on input result. > >>> > > >>> > Normally when validation fails you want to return the user back to > the > >>> > same > >>> > page. If you dispatch back to the input jsp page (instead of > redirect) > >>> > then > >>> > all the input parameters will be there so can be redisplayed with the > >>> > error > >>> > messages. > >>> > > >>> > <result name="input">/myInputPage.jsp</result> > >>> > > >>> > Maybe if you posted your struts config and gave a more detailed > >>> > explanation > >>> > someone could help you with a better solution. > >>> > > >>> > > >>> > On Thu, Oct 29, 2009 at 3:13 PM, Siddiq Syed <siddiq_sa@...> > >>> wrote: > >>> > > >>> >> > >>> >> Hi Greg, > >>> >> > >>> >> Thanks for your quick repley,! > >>> >> > >>> >> The reason for doing a redirect on the input is that system needs to > >>> >> determine what will be the page to display next along with the error > >>> >> messages and the garbage values. > >>> >> > >>> >> As a temporary solution i am using the getter and setter methods of > >>> the > >>> >> variables of View bean ,storing the request values in a temporary > >>> >> session > >>> >> and retriving it in the redirect method of action. and setting back > >>> in > >>> >> the > >>> >> request. -:) which i Guess in not a good approach. > >>> >> > >>> >> But i Guess there should be some way other than the above. > >>> >> > >>> >> > >>> >> Thanks > >>> >> Siddiq. > >>> >> > >>> >> > >>> >> Greg Lindholm-2 wrote: > >>> >> > > >>> >> > The short answer is don't redirect when validation fails. > >>> >> > > >>> >> > For results of "input" you should not be doing a redirect or you > >>> get > >>> >> the > >>> >> > problem you described. > >>> >> > > >>> >> > On Thu, Oct 29, 2009 at 11:13 AM, Siddiq Syed < > siddiq_sa@...> > >>> >> wrote: > >>> >> > > >>> >> >> > >>> >> >> Hi all, > >>> >> >> > >>> >> >> I have been using Glindholm's RedirectMessageInterceptor to > >>> perserve > >>> >> the > >>> >> >> validations/error messages and is working absoulty fine. > >>> >> >> > >>> >> >> But the problem is the values in the fields are not stored. > >>> >> >> > >>> >> >> If a form has 10 fields of which 2 fields are not valid(It does > >>> not > >>> >> pass > >>> >> >> validation), Intercerptor displays the error message but doesnot > >>> shows > >>> >> >> the > >>> >> >> values in the fields of the form. > >>> >> >> > >>> >> >> I hope you guys got the problem. I don't want the user to enter > >>> all > >>> >> the > >>> >> >> values every time even if the validation fails for 1 or 2 field. > >>> >> >> > >>> >> >> Please let me know if you have occured this problem and have the > >>> >> solution > >>> >> >> for the same. > >>> >> >> > >>> >> >> Thanks in advance. > >>> >> >> > >>> >> >> http://glindholm.wordpress.com/ > >>> >> >> > >>> >> >> > >>> >> >> Thanks > >>> >> >> Siddiq. > >>> >> >> -- > >>> >> >> View this message in context: > >>> >> >> > >>> >> > >>> > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26114968.html > >>> >> >> Sent from the Struts - User mailing list archive at Nabble.com. > >>> >> >> > >>> >> >> > >>> >> >> > >>> --------------------------------------------------------------------- > >>> >> >> To unsubscribe, e-mail: user-unsubscribe@... > >>> >> >> For additional commands, e-mail: user-help@... > >>> >> >> > >>> >> >> > >>> >> > > >>> >> > > >>> >> :-(( > >>> >> -- > >>> >> View this message in context: > >>> >> > >>> > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26119066.html > >>> >> Sent from the Struts - User mailing list archive at Nabble.com. > >>> >> > >>> >> > >>> >> > --------------------------------------------------------------------- > >>> >> To unsubscribe, e-mail: user-unsubscribe@... > >>> >> For additional commands, e-mail: user-help@... > >>> >> > >>> >> > >>> > > >>> > > >>> > >>> -- > >>> View this message in context: > >>> > http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26119902.html > >>> Sent from the Struts - User mailing list archive at Nabble.com. > >>> > >>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: user-unsubscribe@... > >>> For additional commands, e-mail: user-help@... > >>> > >>> > >> > >> > > > > > :confused::confused: > -- > View this message in context: > http://old.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26132363.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2Greg 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@... For additional commands, e-mail: user-help@... |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2The 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.
|
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 21) 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_sa@...> 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-unsubscribe@... > > For additional commands, e-mail: user-help@... > > > > > > > > -- > 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@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2First 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. <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.
|
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2On Fri, Oct 30, 2009 at 5:15 PM, Siddiq Syed <siddiq_sa@...> 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_sa@...> > 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-unsubscribe@... > >> > For additional commands, e-mail: user-help@... > >> > > >> > > >> > > >> > >> -- > >> 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@... > >> For additional commands, e-mail: user-help@... > >> > >> > > > > > > -- > 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@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2Hi 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.
![]() |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2Here 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_sa@...> 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_sa@...> > 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_sa@...> > >> 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-unsubscribe@... > >> >> > For additional commands, e-mail: user-help@... > >> >> > > >> >> > > >> >> > > >> >> > >> >> -- > >> >> 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@... > >> >> For additional commands, e-mail: user-help@... > >> >> > >> >> > >> > > >> > > >> > >> -- > >> 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@... > >> For additional commands, e-mail: user-help@... > >> > >> > > > > > :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@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2I don't have any idea why input is throwing this expception. I tried keep the break point in the debug ...but you hardly find where the flow goes. when click on submit with garbage values , first getter,setter methods, than prepare methods than it goes to struts.xml and then come back to getter setter....so on !! As per my understanding , chain is taking the interceport every time and , every time chain call it find the error in the inpterceptor and keep forwarding to the input. God save us from this chain !! <action name="saveInitConsiderationEval" class="com.activity.EvaluateCaseAction" method="saveInitConsiderationEval"> <interceptor-ref name="redirectInput"/><result name="success" type="redirect-action"><param name="actionName">determineCaseEvaluationType</param></result><result name="input" type="chain">determineCaseEvaluationTypeForInput</result><action name="determineCaseEvaluationTypeForInput" class="com.activity.EvaluateCaseAction" ><interceptor-ref name="redirectInput"/><result name="input" type="tiles">${considTypeCode}</result></action> </action> Thanks Siddiq. ________________________________ From: Greg Lindholm <greg.lindholm@...> To: Struts Users Mailing List <user@...> Sent: Mon, November 2, 2009 2:10:57 PM Subject: Re: Preserving Messages and Garbage values Across a Redirect in Struts 2 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_sa@...> 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_sa@...> > 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_sa@...> > >> 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-unsubscribe@... > >> >> > For additional commands, e-mail: user-help@... > >> >> > > >> >> > > >> >> > > >> >> > >> >> -- > >> >> 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@... > >> >> For additional commands, e-mail: user-help@... > >> >> > >> >> > >> > > >> > > >> > >> -- > >> 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@... > >> For additional commands, e-mail: user-help@... > >> > >> > > > > > :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@... > For additional commands, e-mail: user-help@... > > Caused by: Infinite recursion detected: |
|
|
Re: Preserving Messages and Garbage values Across a Redirect in Struts 2both ${} and %{} are supported in 2.1.x
On Mon, Nov 2, 2009 at 11:10 AM, Greg Lindholm <greg.lindholm@...> 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_sa@...> 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_sa@...> >> 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_sa@...> >> >> 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-unsubscribe@... >> >> >> > For additional commands, e-mail: user-help@... >> >> >> > >> >> >> > >> >> >> > >> >> >> >> >> >> -- >> >> >> 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@... >> >> >> For additional commands, e-mail: user-help@... >> >> >> >> >> >> >> >> > >> >> > >> >> >> >> -- >> >> 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@... >> >> For additional commands, e-mail: user-help@... >> >> >> >> >> > >> > >> :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@... >> For additional commands, e-mail: user-help@... >> >> > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
RE: Preserving Messages and Garbage values Across a Redirect in Struts 2Messages are stored since you use RedirectMessageInterceptor.
Action property Data is not retained during redirect. Try following scenarios, Method1: So you need to set explicitly from Action property to ActionContext in Action1 and Need to retrive from the context and set to properties in Action2. Method2: Try to use alias interceptor and put alias through the <param> tag in struts.xml of Action1 and Action2 properties as below. <param name="aliases">#{ 'action1Property1' : 'action2Property1', 'action2Property2' : 'action2Property2'}</param> <interceptor-ref name="alias"/> Method3: Have you tried chain instead of redirectaction and use same properties in Action1 and Action2. Regards, Raghuveer Vellanki -----Original Message----- From: Siddiq Syed [mailto:siddiq_sa@...] Sent: Friday, October 30, 2009 1:43 AM To: user@... Subject: Re: Preserving Messages and Garbage values Across a Redirect in Struts 2 I donno If i can able to explain it to you, I will try my best , here is the secinario Step 1. When the user click the button on the page, depend on the string return from the action method the page will be display and is configured in the struts.xml file as mention below. <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> </action> step 2. There are fields in the pages like 10 text boxes 2 drop down and 2 radio buttons , when I fill all the field and click submit it will do the neccessary business operation and return the string to which page is to display, and is mention in the struts.xml file as mention 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> step 3. : when valiations fails I need to determine on which page validations failed and hence I am forwarding the the input to method which it will determine what page to be displayed. <action name="determineCaseEvaluationTypeForInput" class="us.ga.state.pap.cons.clemency.presentation.action.activity.EvaluateCa seAction" method="determineCaseEvaluationTypeForInput"> <result name="guidelInitConsid" type="tiles">editGuidelinesCaseEvaluation</result> <result name="shrtsntcInitConsid" type="tiles">editShortSentenceCaseEvaluation</result> <result name="sscat2p1InitConsid" type="tiles">editShortSentenceCaseEvaluation</result> </action> I hope you got the sicenario , Its tofugh to explain whatz going on in the mind ! Thanks Siddiq. Greg Lindholm-2 wrote: > > Still don't understand why you need to redirect on input result. > > Normally when validation fails you want to return the user back to the > same > page. If you dispatch back to the input jsp page (instead of redirect) > then > all the input parameters will be there so can be redisplayed with the > error > messages. > > <result name="input">/myInputPage.jsp</result> > > Maybe if you posted your struts config and gave a more detailed > explanation > someone could help you with a better solution. > > > On Thu, Oct 29, 2009 at 3:13 PM, Siddiq Syed <siddiq_sa@...> wrote: > >> >> Hi Greg, >> >> Thanks for your quick repley,! >> >> The reason for doing a redirect on the input is that system needs to >> determine what will be the page to display next along with the error >> messages and the garbage values. >> >> As a temporary solution i am using the getter and setter methods of the >> variables of View bean ,storing the request values in a temporary >> session >> and retriving it in the redirect method of action. and setting back in >> the >> request. -:) which i Guess in not a good approach. >> >> But i Guess there should be some way other than the above. >> >> >> Thanks >> Siddiq. >> >> >> Greg Lindholm-2 wrote: >> > >> > The short answer is don't redirect when validation fails. >> > >> > For results of "input" you should not be doing a redirect or you get >> the >> > problem you described. >> > >> > On Thu, Oct 29, 2009 at 11:13 AM, Siddiq Syed <siddiq_sa@...> >> wrote: >> > >> >> >> >> Hi all, >> >> >> >> I have been using Glindholm's RedirectMessageInterceptor to perserve >> the >> >> validations/error messages and is working absoulty fine. >> >> >> >> But the problem is the values in the fields are not stored. >> >> >> >> If a form has 10 fields of which 2 fields are not valid(It does not >> pass >> >> validation), Intercerptor displays the error message but doesnot shows >> >> the >> >> values in the fields of the form. >> >> >> >> I hope you guys got the problem. I don't want the user to enter all >> the >> >> values every time even if the validation fails for 1 or 2 field. >> >> >> >> Please let me know if you have occured this problem and have the >> solution >> >> for the same. >> >> >> >> Thanks in advance. >> >> >> >> http://glindholm.wordpress.com/ >> >> >> >> >> >> Thanks >> >> Siddiq. >> >> -- >> >> View this message in context: >> >> >> http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redire ct-in-Struts-2-tp26114968p26114968.html >> >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> >> >> >> --------------------------------------------------------------------- >> >> To unsubscribe, e-mail: user-unsubscribe@... >> >> For additional commands, e-mail: user-help@... >> >> >> >> >> > >> > >> :-(( >> -- >> View this message in context: >> http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redire ct-in-Struts-2-tp26114968p26119066.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscribe@... >> For additional commands, e-mail: user-help@... >> >> > > -- View this message in context: http://www.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redire ct-in-Struts-2-tp26114968p26119902.html Sent from the Struts - User mailing list archive at Nabble.com. |
| Free embeddable forum powered by Nabble | Forum Help |