You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Ken McWilliams <ke...@gmail.com> on 2012/11/09 21:47:33 UTC
tiles decoration
I would like to render a tiles definition and put this into the body
attribute and then render an other definition now using that body attribute.
I'm using tiles 3 initialized with the
org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
It probably does not matter but I am using struts2 to render a tiles
definition. To render the definition tiles require a "result type":
To get tiles working with struts2 I do the following:
public void doExecute(String location, ActionInvocation invocation)
throws Exception {
//location = "test.definition"; //for test
setLocation(location);
ServletContext context = ServletActionContext.getServletContext();
ApplicationContext applicationContext =
ServletUtil.getApplicationContext(context);
TilesContainer container =
TilesAccess.getContainer(applicationContext);
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
ServletRequest servletRequest = new
ServletRequest(applicationContext, request, response);
container.render(location, servletRequest);
}
The above works....
I'm using JSPs but I could use freemarker for the views, it it matters.
So how do I render a definition into an attribute and then use that value
in the rendering of another definition?
Re: tiles decoration
Posted by Nicolas LE BAS <ma...@nlebas.net>.
Hi,
Is this what you expect?
<definition name="to.be.used.in.an.attribute" template="sometemplate.jsp">
...
</definition>
<definition name="enclosing.definition" template="layout.jsp">
<put-attribute name="body" value="to.be.used.in.an.attribute" />
</definition>
Of course in your situation, you probably want to use wildcards, but
this is the general idea.
Hope this helps,
Nick
On 12-11-09 03:47 PM, Ken McWilliams wrote:
> I would like to render a tiles definition and put this into the body
> attribute and then render an other definition now using that body attribute.
>
> I'm using tiles 3 initialized with the
> org.apache.tiles.extras.complete.CompleteAutoloadTilesListener
>
> It probably does not matter but I am using struts2 to render a tiles
> definition. To render the definition tiles require a "result type":
>
> To get tiles working with struts2 I do the following:
>
> public void doExecute(String location, ActionInvocation invocation)
> throws Exception {
> //location = "test.definition"; //for test
> setLocation(location);
> ServletContext context = ServletActionContext.getServletContext();
> ApplicationContext applicationContext =
> ServletUtil.getApplicationContext(context);
> TilesContainer container =
> TilesAccess.getContainer(applicationContext);
> HttpServletRequest request = ServletActionContext.getRequest();
> HttpServletResponse response = ServletActionContext.getResponse();
> ServletRequest servletRequest = new
> ServletRequest(applicationContext, request, response);
> container.render(location, servletRequest);
> }
>
> The above works....
>
>
> I'm using JSPs but I could use freemarker for the views, it it matters.
>
> So how do I render a definition into an attribute and then use that value
> in the rendering of another definition?
>