Re: Forward a action from one action programmatically in STruts 2.0

2007-03-20 Thread arunkumar S

Hi Rene,

It works.Thanks

Regards,
Arun.

Maybe this is the option you are searching for:

struts.xml:
---
action name=action1 class=acme.Action1
 result${targetUrl}/result
/action

in your acme.Action1 class:
---
String targetUrl;

public String getTargetUrl() {
return this.targetUrl;
}

public String execute() {
if (...) {
this,targetUrl = 1.jsp;
} else ...
}
}

Regards,
- Rene

arunkumar S schrieb:

Hi,



Thanks for the inputs. my req. will not satisfy your suggestion.



My req. is I have to load different Jsps depending on the user
profile. eg http://profile.eg/. for user with profile = abc,

i will have JSps like 1_abc.jsp,2_abc.jsp,3_abc.jsp

for user with profile = def , i will have jsps like 1_def.jsp,2_def.jsp
etc..







one way of solving this is to mention all the Jsp for users with
different profile in the results and then forward

it in the action itself.



like





action name=action1 class = action1

 result1_abc.jsp/result

 result1_def.jsp/result

/action





action name=action2 class = action2

 result2_abc.jsp/result

 result2_def.jsp/result

/action



return corresponding result in each action based on the users profile.



but the pblm here for each action the application developer has to
define results for each user.

I am thinking of moving this to framework.



Below is the new approach.







action name=action1 class = action1

 result1.jsp/result

/action





action name=action2 class = action2

 result2.jsp/result

/action



action name= *

result/{1}.jsp/result

/action





Now , in an action1.class  action2.class depending on the user
profile i construt 1_abc.action or

1_def.action and 2_abc.action or 2_def.action respectively . and if
i can forward with 1_abc.action the below

definition present in the STruts.xml will take care of forwarding it
to 1_abc.jsp /1_def.jsp  depending on the user automatically.



action name= *

result/{1}.jsp/result

/action



FOr this i need to programmatically forward to an action so that i can
leverage the above mentioned facility.



I hope i have made things clear.Let me know if have any suggestions.









Regards,

Arun.





The way I solve this is by returning the value you want and setting up the
action chain on struts.xml file:

Example:

  class MyAction 1 .. {

  public String execute(){
if(foo)
return foo;
else
return bar;
 }

Then on the Strutus XML file:

 action name= MyAction  class. = 
 result name=foo type=chain FooAction/result
 result name=bar type=chain BarAction/result
...
/action

PS. Make sure you use type=chain!
Hope this helps.

Harring
On 3/15/07, arunkumar S [EMAIL PROTECTED] wrote:

Hi,

I have a requirement where in the action has to be forwarded based on
certain runtime conditions.The destination will be decided only on the
runtime.
---
if(Input = Case1 )
forward action1
else
forward action2.
---

Basically i want to acheive a simple forward( requestdispatcher.forward()
) in
ActionClass in Struts 2.0.

How can we acheive this in Struts 2.0. I dont have any API to acheive
this.

Any inputs pls?


Regards,
Arun


Re: Forward a action from one action programmatically in STruts 2.0

2007-03-16 Thread arunkumar S

Hi,



Thanks for the inputs. my req. will not satisfy your suggestion.



My req. is I have to load different Jsps depending on the user
profile. eg http://profile.eg/. for user with profile = abc,

i will have JSps like 1_abc.jsp,2_abc.jsp,3_abc.jsp

for user with profile = def , i will have jsps like 1_def.jsp,2_def.jsp etc..







one way of solving this is to mention all the Jsp for users with
different profile in the results and then forward

it in the action itself.



like





action name=action1 class = action1

 result1_abc.jsp/result

 result1_def.jsp/result

/action





action name=action2 class = action2

 result2_abc.jsp/result

 result2_def.jsp/result

/action



return corresponding result in each action based on the users profile.



but the pblm here for each action the application developer has to
define results for each user.

I am thinking of moving this to framework.



Below is the new approach.







action name=action1 class = action1

 result1.jsp/result

/action





action name=action2 class = action2

 result2.jsp/result

/action



action name= *

result/{1}.jsp/result

/action





Now , in an action1.class  action2.class depending on the user
profile i construt 1_abc.action or

1_def.action and 2_abc.action or 2_def.action respectively . and if
i can forward with 1_abc.action the below

definition present in the STruts.xml will take care of forwarding it
to 1_abc.jsp /1_def.jsp  depending on the user automatically.



action name= *

result/{1}.jsp/result

/action



FOr this i need to programmatically forward to an action so that i can
leverage the above mentioned facility.



I hope i have made things clear.Let me know if have any suggestions.









Regards,

Arun.





The way I solve this is by returning the value you want and setting up the
action chain on struts.xml file:

Example:

  class MyAction 1 .. {

  public String execute(){
if(foo)
return foo;
else
return bar;
 }

Then on the Strutus XML file:

 action name= MyAction  class. = 
 result name=foo type=chain FooAction/result
 result name=bar type=chain BarAction/result
...
/action

PS. Make sure you use type=chain!
Hope this helps.

Harring
On 3/15/07, arunkumar S [EMAIL PROTECTED] wrote:

Hi,

I have a requirement where in the action has to be forwarded based on
certain runtime conditions.The destination will be decided only on the
runtime.
---
if(Input = Case1 )
forward action1
else
forward action2.
---

Basically i want to acheive a simple forward( requestdispatcher.forward()
) in
ActionClass in Struts 2.0.

How can we acheive this in Struts 2.0. I dont have any API to acheive
this.

Any inputs pls?


Regards,
Arun


Forward a action from one action programmatically in STruts 2.0

2007-03-15 Thread arunkumar S

Hi,

I have a requirement where in the action has to be forwarded based on
certain runtime conditions.The destination will be decided only on the
runtime.
---
if(Input = Case1 )
forward action1
else
forward action2.
---

Basically i want to acheive a simple forward( requestdispatcher.forward() ) in
ActionClass in Struts 2.0.

How can we acheive this in Struts 2.0. I dont have any API to acheive this.

Any inputs pls?


Regards,
Arun