You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Pratt <th...@gmail.com> on 2007/11/10 21:46:58 UTC

Re: tiles usage

On Nov 10, 2007 6:35 AM, Zhang, Larry (L.) <lz...@ford.com> wrote:
> Consider that each page can have different .css and .js files and these files will be put between <head>and </head> in the layout, then the question is that how to pass the specific .css and .js to the tiles layout? I definitely don't want to put all the .css and .js to the layout just for suite to use tile. Thanks in advance
>
I solved the problem like this.  In my layout I have code like this:

  <head>
    <title>${title}</title>
    <link rel="SHORTCUT ICON" type="image/vnd.microsoft.icon"
href="${pageContext.request.contextPath}images/favicon.ico" />
    <link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath}css/default.css"
title="default" />
    <c:forEach items="${styles}" var="s">
      <link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath}${s}" />
    </c:forEach>
    <tiles:insertAttribute name="style" ignore="true"/>
    <script language="JavaScript" type="text/javascript"
src="${pageContext.request.contextPath}script/util.js"></script>
    <c:forEach items="${scripts}" var="s">
      <script language="JavaScript" type="text/javascript"
src="${pageContext.request.contextPath}${s}"></script>
    </c:forEach>
    <script language="JavaScript" type="text/javascript">
      <tiles:insertAttribute name="script" ignore="true"/>

      /**
       * Page Level Initialization
       */
      function init () {
        <tiles:insertAttribute name="init" ignore="true"/>
      } //onLoad
    </script>
  </head>

This allows specifying a list of additional css files, a specific
<style> section, a list of additional javascript files, specific
javascript routines and special onload initialization code.  For
example, one of the more specialized definitions I have in my
tiles.xml looks like:

  <definition name="site-manager" extends="default-layout">
    <put-attribute name="title" value="Anodyzed - Site Manager" type="string"/>
    <put-attribute name="body" value="/body/site-manager.jsp" type="template"/>
    <put-list-attribute name="styles">
      <add-attribute value="/css/tab.css" type="string"/>
    </put-list-attribute>
    <put-list-attribute name="scripts">
      <add-attribute value="/script/cookies.js" type="string"/>
      <add-attribute value="/script/duallist.js" type="string"/>
      <add-attribute value="/script/tab.js" type="string"/>
      <add-attribute value="/script/list.js" type="string"/>
      <add-attribute value="/script/sarissa.js" type="string"/>
      <add-attribute value="/script/javeline_xpath.js" type="string"/>
      <add-attribute value="/script/javeline_xslt.js" type="string"/>
      <add-attribute value="/script/sarissa_dhtml.js" type="string"/>
      <add-attribute value="/script/sarissa_ieemu_xpath.js" type="string"/>
    </put-list-attribute>
  </definition>

That's how I solved the problem.  Hope that helps.
  (*Chris*)

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