Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Action code reuse

 
Mike Nason
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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?
 
sarada bokka
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • 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
  • 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;

}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic