开发者

Tiles2 group all the scripts inside a ¿definition?

I'm using struts2+tiles2, and I would like to do the following. I have a baseLayout, where I define my menu, body, etc like this:

<tiles:insertAttribute name="menu" />
<tiles:insertAttribute name="body" />

And then in my tiles.xml I set them like this:

<definition name="/index" extends="baseLayout">    
    <put-attribute name="title" value="/public/menu.jsp" />
    <put-attribute name="body" value="/public/index.jsp" />
</definition>

So, some times I have more complex layouts where I can use several jsp in the body, and some of this jsp have some inline scripts. I would like to know if there is any way I can set all these inline scripts to be appended on the same place. So for example, I would like to define the page head in the baseLayout, and then have all the inline scripts appended to 开发者_JAVA技巧this head. I hope there is a way to do this, but I find the tiles documentation very confusing and I haven't discovered a way to do this.

Thanks!


In tiles1 I've done stuff like this:

baseLayout.jsp
<html>
    <head>
        <tiles:getAsString name="appendedFiles"/>
    </head>
<body>
<tiles:insert attribute="menu">
<tiles:insert attribute="body">
</body>
</html>

tiles-defs.xml
<definition name="baseLayout" path="/struts/baseLayout.jsp">
  <put name="cssfiles"><![CDATA[
    <link href="file1.css" rel="stylesheet" type="text/css">
    <link href="file2.css" rel="stylesheet" type="text/css">
  ]]></put>
</definition>

Alternatively you can put the content into a separate jsp and then "tiles:insertAttribute" like any other content.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜