On Jun 8, 2006, at 9:05 AM, Susan G. Conger wrote:

First, my header.jsp has a section where the graphic changes depend
on what page is begin displayed. I can't seem to figure out the correct way
to implement this.

The short answer is to use Tile attributes. The longer answer is that attributes don't always work the way you might think. One of the weaknesses of Tiles is that there's no good way to pass data from one tile to another. Attributes are better suited for static parameter substitution.

For example suppose you have Tile A that defines some attributes and Tile B that extends Tile A and overrides some attributes as follows:

<definition name="tileA" path="/layout.jsp">
  <put name="headerGraphic" value="image1.gif"/>
  <put name="someOtherThing" value="..."/>
</definitioin>

<definition name="tileB" extends="tileA">
  <put name="headerGraphic" value="image2.gif"/>
</definition>

As long as your layout is completely defined in one JSP page this will all work. It breaks down if your layout has separate pages for header, footer, etc. See below:

<definition name="tileA" path="/layout.jsp">
  <put name="header" value="/header1.jsp"/>
  <put name="headerGraphic" value="image1.gif"/>
  <put name="someOtherThing" value="..."/>
</definitioin>

<definition name="tileB" extends="tileA">
  <put name="header" value="header2.jsp"/>
  <put name="headerGraphic" value="image2.gif"/>
</definition>

Above you want to define your header differently for two layouts and you want to pass different images in. This won't work because the headerGraphic attribute will not be passed along to the header page unless you do it manually from the page where it is inserted. There's a couple ways to hack this. One is described in another thread:

http://mail-archives.apache.org/mod_mbox/struts-user/200605.mbox/% [EMAIL PROTECTED]

The other would be, as you indicated in the subject, to embed a tile within a tile:

<definition name="tileA" path="/layout.jsp">
  <put name="header" value="headerTile1"/>
  <put name="someOtherThing" value="..."/>
</definitioin>

<definition name="tileB" extends="tileA">
  <put name="header" value="headerTile2"/>
</definitioin>

<definitiion name="headerTile1" path="/header.jsp">
  <put name="headerGraphic" value="image1.jpg"/>
</definition>

<definitiion name="headerTile2" path="/header.jsp">
  <put name="headerGraphic" value="image2.jpg"/>
</definition>

I haven't tried this, but I don't think it works out of the box. In layout.jsp when you insert the header tile, you'll have to do some magic I think to resolve the name to a tile definition. This should be better supported and hopefully will eventually.

Also do I need an html/jsp page to display this image
change or can I just point to the gif file?

If I understand you correctly I think you should be able to just point to the image file.

HTH,
Greg



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to