• 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

Action code reuse

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We have site to browse catalog and some actions+jsp:
1. ShowItems + listItems.jsp - to show list of categories = start page
2. ShowProductList + listProducts.jsp - to show list of products
3. ShowProductDetails + productDetails.jsp - to show product details.

The thing is when user clicks on ShowProductList and list contains one item the result should be ShowProductDetails.
I have an idea to reuse ShowProductDetails and I need to do it without send redirect (because it's bad for client performance)

I have an idea to use ActionChaining but don't know how to do it, because these 2 actions have different params, and
patterns doesn't work as in type="redirect-action".
I need to be able to pass params from one action to another. Any ideas?
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am also new to struts2 .

you have mentioned 2 actions have different params

and then you said I need to be able to pass params from one action to another. Any ideas?

I guess this may help you

Struts.xml



login.jsp page

<s:form action="chain1.action" method="POST">

in the above Chain1Action parameters are carried to Chain2Action

is this you are looking for?
 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I forgot to mention this

You can get the Chain1Action param username in Chain2Action as below

public class Chain2Action extends ActionSupport{
private String password;
public String execute() throws Exception {

ActionContext context=ActionContext.getContext();
System.out.println("value stack value"+context.getValueStack().findString("username"));


return SUCCESS;

}
reply
    Bookmark Topic Watch Topic
  • New Topic