You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matt Kurjanowicz <ma...@gmail.com> on 2006/08/02 15:37:07 UTC

Nested tiles layouts

Hi,
  I've seen a few threads similar to this, but nothing with my specific problem.

  Suppose I have a tiles definition file, with the following definitions:
  <definition name=".default" page="/stdLayout.jsp">
    <put name="title" value="Default Title" type="string" />
    <put name="css" value="/css/main.css" />
    <put name="content" value="/defaultContent.jsp" />
  </definition>

  <definition name=".lib.layout" page="/lib/layout.jsp">
    <put name="libContent" value="/lib/default.jsp" />
  </definition>

  <definition name=".lib.default" extends=".default">
    <put name="css" value="/css/lib/lib.css" />
    <put name="content" value=".lib.layout" type="definition" />
  </definition>

  <definition name=".lib.home" extends=".lib.default">
    <put name="title" value="Library Home" />
    <put name="libContent" value="/lib/home.jsp" />
  </definition>

  Now suppose that I have the following JSP pages:
  stdLayout.jsp:
  <html>
    <head><title><tiles:getAsString name="title" /></title></head>
    <body>
      <link rel="stylesheet" type="text/css" href="<tiles:getAsString
name="css" />" />
      <tiles:insert name="content" />
    </body>
  </html>

  defaultContent.jsp:
  THIS SHOULD NEVER SHOW UP

  /lib/layout.jsp
  <hr />
  <tiles:insert name="libContent" />
  <hr />

  /lib/default.jsp
  LIB DEFAULT

  /lib/home.jsp
  LIB HOME

  Now, what I would expect when going to .lib.home is the following:
  <TITLE>: Library Home

  -----------------------------------------------------------------------
  LIB HOME
  -----------------------------------------------------------------------

  Instead, I get:
  <TITLE>:
  ----------------------------------------------------------------------
  THIS SHOULD NEVER SHOW UP
  ----------------------------------------------------------------------


  So basically, every property that is inerited from ".default" can be
overridden, but no property in ".lib.default" (namely the libContent
property) can be overridden.

Is there any way around this?

(Please disregard any syntax errors above - it is merely an example
and not the actual code)

Thanks,
Matt Kurjanowicz

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


Re: Nested tiles layouts

Posted by Antonio Petrelli <br...@tariffenet.it>.
Antonio Petrelli ha scritto:
> <definition name=".lib.home" extends=".lib.default">
>   <put name="title" value="Library Home" />
>   <put name="libContent" value=".lib.layout.new" />
> </definition>

Whoops, I actually meant:

<definition name=".lib.home" extends=".lib.default">
  <put name="title" value="Library Home" />
  <put name="content" value=".lib.layout.new" />
</definition>


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


Re: Nested tiles layouts

Posted by Antonio Petrelli <br...@tariffenet.it>.
Matt Kurjanowicz ha scritto:
> That is what I get - sorry I confused myself with my example.

No problem, I thought really it was a Tiles bug :-)
Ok if I understood you correctly, you wish to override an attribute that 
has been put inside another definition, right?
In this case, you cannot do this directly (though in Standalone Tiles I 
posted a patch about nested definitions, but that's another story), you 
have to create a new definition that extends .lib.layout and use this 
one inside .lib.home.


 <definition name=".lib.layout.new" extends=".lib.layout">
   <put name="libContent" value="/lib/home.jsp" />
 </definition>

 <definition name=".lib.home" extends=".lib.default">
   <put name="title" value="Library Home" />
   <put name="libContent" value=".lib.layout.new" />
 </definition>

HTH
Antonio

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


Re: Nested tiles layouts

Posted by Matt Kurjanowicz <ma...@gmail.com>.
On 8/2/06, Antonio Petrelli <br...@tariffenet.it> wrote:

> <snip>
> <TITLE>: Library Home
>  ----------------------------------------------------------------------
> LIB DEFAULT
>  ----------------------------------------------------------------------
> </snip>
>
>
> Ciao
> Antonio
>

That is what I get - sorry I confused myself with my example.
-Matt

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


Re: Nested tiles layouts

Posted by Antonio Petrelli <br...@tariffenet.it>.
Matt Kurjanowicz ha scritto:
> Hi,
>  I've seen a few threads similar to this, but nothing with my specific 
> problem.
>
>  Suppose I have a tiles definition file, with the following definitions:
> ...
>  Now suppose that I have the following JSP pages:
>  stdLayout.jsp:
>  <html>
>    <head><title><tiles:getAsString name="title" /></title></head>
>    <body>
>      <link rel="stylesheet" type="text/css" href="<tiles:getAsString
> name="css" />" />
>      <tiles:insert name="content" />
>    </body>
>  </html>

I calculated the final result of .lib.home definition and it should be:

<definition name=".lib.home" page="/stdLayout.jsp">
   <put name="title" value="Library Home" />
   <put name="libContent" value="/lib/home.jsp" />
   <put name="css" value="/css/lib/lib.css" />
   <put name="content" value=".lib.layout" type="definition" />
</definition>

But standardLayout has no "libContent" attribute, so it is ignored. 
Anyway if you really got:

<snip>
<TITLE>:
 ----------------------------------------------------------------------
 THIS SHOULD NEVER SHOW UP
 ----------------------------------------------------------------------
</snip>

then it seems that Tiles engine did not replace the "content" attribute, 
you should get:

<snip>
<TITLE>: Library Home
 ----------------------------------------------------------------------
LIB DEFAULT
 ----------------------------------------------------------------------
</snip>

It seems like a bug to me...

Ciao
Antonio


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