Hi,
Sorry, my previous posting was messed up by Roomity.
I need to insert some dynamic jsp codes into my pages using tiles with
Struts 1.2.4.
The following examples don't seem to insert really dynamic jsp. It's for
illustration purpose.
tiles-defs.xml:
<definition extends="logindefault" name="login.view"
controllerClass="MyTilesController">
<put name="sidebar" type="string">
<h1><bean:message key=\"site.menu.header\"/></h1>
</put>
<put name="body-content" value="login.jsp" />
</definition>
in my jsp page, using tiles:insert or tiles:getAsString doesn't work as an
exception occurs. It complains that "sidebar" is not found.
I also tried to use a controller class:
<definition extends="logindefault" name="login.view"
controllerClass="MyTilesController">
<put name="sidebar" value="sidebar"/>
<put name="body-content" value="login.jsp" />
</definition>
MyTilesController.java implements org.apache.struts.tiles.Controller
public void perform(ComponentContext context, HttpServletRequest arg1,
HttpServletResponse arg2, ServletContext arg3) throws ServletException,
IOException {
context.putAttribute("sidebar", "<h1><bean:message key=\"
site.menu.header\"/></h1>");
}
If I use <tiles:getAsString name="sidebar"/>, the "<bean:message key=\"
site.menu.header\"/>" part is displayed as it is(no dynamic data is
generated).
If I use <tiles:insert attribute="sidebar"/>, nothing is displayed
please help.
The problem I am trying to solve is that I have a bunch of "tokens" that are
just struts tags and html markups.
Each jsp pages can have a bunch of tokens.
All the tokens and their definitions are loaded into a hashtable.
I want to pass in the token definitions to a tile definition at runtime so
that I can generate the final jsp page.
The simplest solution is to put each token's definition into a jsp page.
<definition extends="logindefault" name="login.view"
controllerClass="MyTilesController">
<put name="sidebar" value="sidebar.jsp"/>
<put name="body-content" value="login.jsp" />
<put name="token1" value="token1.jsp" />
<put name="token2" value="token2.jsp" />
<put name="token3" value="token3.jsp" />
</definition>
But a page may have a lot of tokens. so I want to know if I can get around
creating jsp pages for all the tokens.
Thanks.
Kai