You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Daniel PC Leung <pc...@gmail.com> on 2005/02/22 02:32:08 UTC

How can the controller class of Tiles get the attribute of other Action class?

I have the following controller class.
I would like to change the parameter of
createMenuItem dynamically based on the 
user group after login.

How can the controller class of Tiles get the attribute of
of other Action class?

Thanks

public class MyMenuAction implements Controller  {
	private MenuItem createMenuItem (String label, String link) {
	    SimpleMenuItem item = new SimpleMenuItem();
	    item.setLink(link);
	    item.setValue(label);
	    return item;
	  }
	  private List getLinks() {
	    List list = new ArrayList();
	    list.add(createMenuItem ("Option1", "/option1"));
	    list.add(createMenuItem ("Option2", "/option2"));
	    list.add(createMenuItem ("Option3", "/option3"));
	    return list;
	  }

	  public void perform (ComponentContext context,
	                       HttpServletRequest request,
	                       HttpServletResponse response,
	                       ServletContext servletContext)
	                throws ServletException, IOException {
	    List items = (List) getLinks();
	    context.putAttribute ("items", items);
	  }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org