Re: Dynamic Result Selection

2011-11-19 Thread rohan jamkhedkar
Hi Christian,
        Thank you for your response. I had actually defined all three results, 
success, input and error and My class did extend ActionSupport. But the problem 
was, whenever an error occurred during Interceptor invocation, framework would 
try to find value of nextPage. As action is not executed it would not find 
nextPage on valueStack. So I want to know is there any way of getting around 
this problem? Can I specify value for nextPage before any interceptor is 
invoked?

Thanks  Regards,
Rohan



 From: Christian Grobmeier grobme...@gmail.com
To: Struts Users Mailing List user@struts.apache.org; rohan jamkhedkar 
rgjamkhed...@yahoo.co.in 
Sent: Saturday, 19 November 2011 1:21 PM
Subject: Re: Dynamic Result Selection
 
Hello Rohan,

On Sat, Nov 19, 2011 at 8:44 AM, rohan jamkhedkar
rgjamkhed...@yahoo.co.in wrote:

 result name=success%{nextPage}/result

try to add these results too:

result name=input%{nextPage}/result
result name=error%{nextPage}/result

Input is what is returned when some input is missing, error in case an
error happens.
Please also see the class ActionSupport, were these String constants
are defined. To use it, extend ActionSupport and return for example:
return SUCCESS;

Of course you don't need to use ActionSupport, but I think it is a good idea 
:-)

Cheers
Christian


-- 
http://www.grobmeier.de
https://www.timeandbill.de




Re: Dynamic Result Selection

2011-11-19 Thread rohan jamkhedkar
Hi Christian,
Thanks again. I think I would have to write my own interceptor. I think I can 
also get nextPage value from session. i.e. I can set value from my interceptor 
to a session variable and also from action and then use it. I would try doing 
that. And if it works out, I would certainly post it. 

Thanks  Regards,
Rohan




 From: Christian Grobmeier grobme...@gmail.com
To: rohan jamkhedkar rgjamkhed...@yahoo.co.in 
Cc: Struts Users Mailing List user@struts.apache.org 
Sent: Saturday, 19 November 2011 1:42 PM
Subject: Re: Dynamic Result Selection
 
On Sat, Nov 19, 2011 at 9:06 AM, rohan jamkhedkar
rgjamkhed...@yahoo.co.in wrote:
 Hi Christian,
         Thank you for your response. I had actually defined all three
 results, success, input and error and My class did extend ActionSupport. But
 the problem was, whenever an error occurred during Interceptor invocation,
 framework would try to find value of nextPage. As action is not executed it
 would not find nextPage on valueStack. So I want to know is there any way of
 getting around this problem? Can I specify value for nextPage before any
 interceptor is invoked?

Ah, now I understand better.

Have you tried to define a default value for $nextPage in your class? Like:
class MyAction {
private String nextPage = errorpage.jsp;

Actually the action itself will not be executed if an interceptor error occurs.
If the default value does not work, I think it might be a good idea to
write an own interceptor which catches something like that or to
extend the throwing interceptor to put a correct value into the
object.

cheers
Christian


 Thanks  Regards,
 Rohan

 
 From: Christian Grobmeier grobme...@gmail.com
 To: Struts Users Mailing List user@struts.apache.org; rohan jamkhedkar
 rgjamkhed...@yahoo.co.in
 Sent: Saturday, 19 November 2011 1:21 PM
 Subject: Re: Dynamic Result Selection

 Hello Rohan,

 On Sat, Nov 19, 2011 at 8:44 AM, rohan jamkhedkar
 rgjamkhed...@yahoo.co.in wrote:

 result name=success%{nextPage}/result

 try to add these results too:

 result name=input%{nextPage}/result
 result name=error%{nextPage}/result

 Input is what is returned when some input is missing, error in case an
 error happens.
 Please also see the class ActionSupport, were these String constants
 are defined. To use it, extend ActionSupport and return for example:
 return SUCCESS;

 Of course you don't need to use ActionSupport, but I think it is a good idea
 :-)

 Cheers
 Christian


 --
 http://www.grobmeier.de
 https://www.timeandbill.de






-- 
http://www.grobmeier.de
https://www.timeandbill.de




Dynamic Result Selection

2011-11-18 Thread rohan jamkhedkar
Hi All,
       I am very new to Struts 2, so I don't know whether this issue is 
discussed before and has a solution. I had dynamic Result selection in my 
project. Where result would be selected on the basis of execution logic in 
Action method. 
For Example something like,
action name=test class=myPackage.Test 
result name=success%{nextPage}/result
/action 
Where nextPage would be a property in Test class with settter and getter 
methods. And I would set it to whatever jsp page I want to execute.

It would work fine if Action method is successfully executed.
But the problem was that, if something happened and Action could not be 
executed, then result would not get invoked. i.e. if validation interceptor 
found validation errors or my RolesInterceptor found that user does not have 
access to that method. 
Framework would throw exception that result not found.
What can be done here?? Can I set a default nextPage before Interceptors are 
invoked?? Could writing an Interceptor for that help?? 

I know that as I am new to Struts 2 I could be doing something wrong. Can 
anyone help me??