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...@yahoo.com> 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...@yahoo.com>
>> 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...@yahoo.com>
>> >> 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-unsubscr...@struts.apache.org
>> >> >> For additional commands, e-mail: user-h...@struts.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >> :-((
>> >> --
>> >> 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-unsubscr...@struts.apache.org
>> >> For additional commands, e-mail: user-h...@struts.apache.org
>> >>
>> >>
>> >
>> >
>>
>> --
>> 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-unsubscr...@struts.apache.org
>> For additional commands, e-mail: user-h...@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Preserving-Messages-and-Garbage-values-Across-a-Redirect-in-Struts-2-tp26114968p26131518.html
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to