How to Use TilesAction class for dynamically changing the tile attribute
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Adriano_Goulart
Posted On:   Tuesday, November 7, 2006 02:03 PM

I extend the TilesAction class to achieve a dynamic attribute changing in Tiles. But it seems a little bit complicated. In my struts-config file, I added two actions : Then, in my tiles-defs, I included the following : controllerUrl="/TilesExtra.do" /> So, when I call InstExtra.do, it will call tiles.inst.extra that in trun will call TilesExtra.do that will display and pick a parameter to replace an attribute for tiles to use. The following is the code for the DisplayHTMLAction that is being called by the TilesExtra.do :    More>>

I extend the TilesAction class to achieve a dynamic attribute changing in Tiles.

But it seems a little bit complicated.



In my struts-config file, I added two actions :


			













Then, in my tiles-defs, I included the following :


			

controllerUrl="/TilesExtra.do" />








So, when I call InstExtra.do, it will call tiles.inst.extra that in trun will call TilesExtra.do
that will display and pick a parameter to replace an attribute for tiles to use.


The following is the code for the DisplayHTMLAction that is being called by the TilesExtra.do :


			
...

public class DisplayHTMLAction extends TilesAction {



public ActionForward execute(ComponentContext context, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception {



String page = request.getParameter("page");


if (page != null) {

context.putAttribute("body", "/html/" + page);

}

return mapping.findForward("forward");

}

}




It seems to be a bit complicated to do all this back and forth, despite the fact that it worked as I expected.


Does anybody knows a better way to accomplish the same ?

   <<Less
About | Sitemap | Contact