tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Tim Kannenberg" <tkann...@celerasystems.com>
Subject RE: Question re: attribute evaluation
Date Wed, 13 Feb 2008 20:28:20 GMT
Thanks, Antonio.  Unfortunately, I think I chose an example which
doesn't do a very good job of illustrating what I'm actually trying to
accomplish, so let me try to explain more fully.

I'm working on a Struts 2 web application which has several very similar
pages, each of which contains some form fields used to capture search
criteria, along with a table displaying a set of search results which
match the specified criteria.  Each page allows you to search for a
different type of thing (cars, airplanes, boats, etc.), so the set of
search criteria fields differs from one page to the next, as does the
set of columns required to display the results.  However, the basic
layout is consistent from one page to the next, as is some of the markup
for the results table (for example, odd-numbered <tr> elements are
assigned a different class so they can easily be displayed with a
different background color).  I'd like to factor all of this common
stuff (including the Struts <s:form> tags and the <tr> tags) the out
into my template, so that the individual pages which use that template
only have to specify the appropriate set of form fields and the
corresponding set of result row columns.  In effect, I'm trying to do
something analogous to having an abstract search page (the template)
from which other pages (my individual search pages) can inherit,
overriding only the pieces which control the rendering of the form
fields and the result row columns.

I tried to do this by having the individual pages specify the JSP text
needed to render the form fields and the row content using
<tiles:putAttribute>, but it seems like that's not going to work, since
the tag body is evaluated *before* the attribute is substituted into the
template, not after.  From reading about list attributes, I don't think
that mechanism is going to do what I need, either.  Is there a different
approach I can use to achieve the desired results using Tiles?

| -----Original Message-----
| From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com]
| Sent: Wednesday, February 13, 2008 2:00 PM
| To: users@tiles.apache.org
| Subject: Re: Question re: attribute evaluation
| I think I misunderstood your question, sorry.
| I will try to answer better this time.
| 2008/2/13, Tim Kannenberg <tkannenb@celerasystems.com>:
| > Because ${current} is undefined when the body content is evaluated,
| produces a table with 5 rows, each of which contains a single cell
| nothing in it.  Is this an unavoidable consequence of the way Tiles
| or is there a way to make Tiles treat the content of the putAttribute
| as a literal string to be inserted into the template and then
| along with the rest of the template page?
| It is unavoidable, since the JSP page put inside the
| <tiles:putAttribute> tag body is evaluated *before* putting it as an
| attribute value.
| But in your particular case, why don't you use a list attribute?
| http://tiles.apache.org/tutorial/advanced/list-attributes.html
| Ciao
| Antonio

View raw message