• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how can I make two actions communicate with each other

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

The problem is like :

1) jsp 1 calls jsp 2 for some calculation.
2) jsp 2 calls action2 and does all the processing and mapping.findforward("jsp1"), will redirect to jsp1.
3) now, action1 should continue its working with the values returned by action2.

suppose these values are totalAmount and totalDistance;

I am not able to get totalAmount and totalDistance in action1.

I have taken the same variable names in form1 and form2 as totalDistance and totalAmount and provided the getters and setters in both forms.

could anyone give idea why these variables are not giving any value in action1. they are assigned proper values in action 2.


Please suggest.

Thanks in advance
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there something wrong with this?

1) jsp 1 calls jsp 2 for some calculation.
2) jsp 2 calls action2 and does all the processing and mapping.findforward("jsp1"), will redirect to jsp1.
3) now, action1 should continue its working with the values returned by action2.



Where action1 is called?
 
amit gupta
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rogel garcia wrote:Is there something wrong with this?

1) jsp 1 calls jsp 2 for some calculation.
2) jsp 2 calls action2 and does all the processing and mapping.findforward("jsp1"), will redirect to jsp1.
3) now, action1 should continue its working with the values returned by action2.



Where action1 is called?




my apologies for not being clear .

jsp1 -> action1, on click of a button on jsp 1, jsp 2 is called and then action 2.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you mean action 1 should "continue" with values from action 2? There is no "continue": it's a new request.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use type=chain to navigate from one action to another in struts2

example :
<action name="makerDetails" class="abcAction">
<result name="redirect-abc" type="chain">
<param name="actionName">venus</param>
<param name="namespace">/wm</param>
</result>
</action>
 
rogel garcia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Action1 -> JSP1 ... then onclick -> Action2 -> JSP2?? Correct?

And you want that Action1 execute something based on what Action2 has calculated?

Or from Action2 do you want to dispatch to Action1 again?


Like David asked:

What do you mean action 1 should "continue" with values from action 2?


 
amit gupta
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

rogel garcia wrote:Action1 -> JSP1 ... then onclick -> Action2 -> JSP2?? Correct?

And you want that Action1 execute something based on what Action2 has calculated?

Or from Action2 do you want to dispatch to Action1 again?


Like David asked:

What do you mean action 1 should "continue" with values from action 2?





I want Action1 execute something based on what Action2 has calculated, after Action2 has dispatched to action1.

basically , these are two different requests , as mentioned above.

the problem is I am not able to use the resulting values of Action 2 in Action1.

I hope this clarify the problem.



 
rogel garcia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
putting some attributes in the session does not solve the problem??

In Action2:

request.getSession().setAttribute("myvalue", xyz);


In Action1:

Object xyz = request.getSession().getAttribute("myvalue");

??
 
amit gupta
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:What do you mean action 1 should "continue" with values from action 2? There is no "continue": it's a new request.



David,

I meant

1) jsp1->action1->(executes search)->(some search values are displayed on jsp1)->
2) jsp1(using javascript on click of a button )->jsp2() ->Action 2(perform something and gives "result")->forwarded to jsp1 using mapping.findforward().


now the "result" is not accessible on form1/action1/jsp1

is there any way I can access the values available on action2 directly from action1.

in jsp1 if I use , it shows the value of "result" properly.

But I dont want to use scriptlet in jsp.

Please suggesst.

Thanks
 
rogel garcia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to set an attribute...

A request one will be enought


In action2:

request.setAttribute("result", mylist);


In JSP1:

${result}
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
${result}

use EL.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic