Nicolas Le Bas <mail@...> writes:
> I've been looking at this pull request, and I like it. I understand its
> value, but it raises a number of interesting challenges and questions.
>
> *Summary*
>
> Brett wants to support evaluation of expressions in the attributes of
> <item>.
Thankyou. To be precise, I'm looking for evaluations of expressions on any
attribute that can contain multiple values. mck's solution that
`add-list-attribute` can be used, while verbose is sufficient, however;
presently an NPE is being thrown on the use of the `expression` attribute on
`add-list-attribute`.
My exceptions are somewhat swallowed, but as far as I can gather without further
traces I'm recieving:
Caused by: java.io.IOException:
ServletException including path '/WEB-INF/layout/web-base.jsp'.
at org.apache.tiles.request.servlet.ServletUtil
.wrapServletException(ServletUtil.java:61)
at org.apache.tiles.request.servlet.ServletRequest
.forward(ServletRequest.java:267)
at org.apache.tiles.request.servlet.ServletRequest
.doForward(ServletRequest.java:228)
at org.apache.tiles.request.AbstractClientRequest
.dispatch(AbstractClientRequest.java:57)
at org.apache.tiles.request.render.DispatchRenderer
.render(DispatchRenderer.java:47)
at org.apache.tiles.impl.BasicTilesContainer
.render(BasicTilesContainer.java:259)
at org.apache.tiles.impl.BasicTilesContainer
.render(BasicTilesContainer.java:397)
... 78 more
Caused by: java.lang.NullPointerException
at org.apache.taglibs.standard.tag.common.core.OutSupport
.out(OutSupport.java:179)
at org.apache.taglibs.standard.tag.common.core.OutSupport
.doStartTag(OutSupport.java:99)
...
at org.apache.tiles.request.servlet.ServletRequest
.forward(ServletRequest.java:265)
... 83 more
> *Challenges*
>
> - <item> and <bean> are excluded from Tiles 3.x, they are only supported
> as backwards compatibility in tiles-compat, and only in the XML
> definition file. They cannot be used as part of an inline definition
> (through the use of
> <tiles:definition><tiles:put-list-attribute>...</...> in a JSP template).
That's fine, I'm happy to use newer approaches, I just found `MenuItem` at the
time of a way to create tuples as attributes, previously I thought all
attributes were single values/expressions in lists.
> - This change would somehow break backwards compatibility (an old
> application would display the string "${customer.id}" instead of
> "12345", this might be expected by those applications that came all the
> way from struts 1)
>
> - All other tags in tiles-defs.xml require the developer to specify
> explicitely that she wants the expression evaluated: <add-attribute
> expression="${customer.id}"/> instead of <add-attribute value="Customer
> ID"/>. Doing differently for <item> would make this XML even more
> confusing that it already is.
>
> *Questions*
>
> - Do we want to keep maintaining <item> and <bean>, given that today DI
> frameworks provide several better ways to declare those beans? Do we
> want to reintegrate these out of tiles-compat into tiles-core?
>
> - I see the value in merging the "value" and "expression" attributes.
> However I do not think it should be done as part of a minor release in
> TILES_3_0_X and not without automated tests. So IMHO options would be:
> use the "expression" attribute in <item> for a uniform syntax and
> backwards compatibility, or merge the "expression" and "value"
> attributes accross the board in a major release (3.1?).
I would LOVE to see tiles have a single attribute for both expression and value
and an attribute to turn expression evaluation on/off. The reason I say this is
it would IMHO simplify the definition and should simplify tiles internally by
use of a single value. A second attribute "evaluate" could be supplied on any
attribute which could cascade to lower levels.
> I think it is difficult to understand all aspects of Tiles as it is now,
> and we should assist Brett in prefecting his design.
My solution has come about quite likely to my lack of understanding tiles in
full. I would love to help contribute more with some of the documentation, as
prior today I didn't really know about `add-list-attribute`; apart from the DTD
and API documentation there's no reference to it in the examples or any uses I
could find within google searches.