mck <mck@...> writes:
>
> Sorry for my very late reply. It's been a bit chaotic of late.
>
> > - 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.
>
> Brett, why were you using <item> instead of <put-attribute> inside the
> <put-list-attribute> ?
> Is it only because you want two values? (ie value and link)
>
> Could there be other ways to solve this with tags that are supported in
> tiles-3
>
> For example something likeā¦
>
> <put-list-attribute name="breadcrumbs">
> <add-list-attribute name="customer.id">
> <add-attribute expression="${customer.id}" />
> <add-attribute
> expression="/customers/${customer.id}/salesOrders" />
> </add-list-attribute>
> <add-list-attribute name="order.id">
> <add-attribute expression="${order.id}" />
> <add-attribute
> expression="/customers/${customer.id}/salesOrders" />
> </add-list-attribute>
> </put-list-attribute>
>
> > - Do we want to keep maintaining <item> and <bean>, given that today DI
> > frameworks provide several better ways to declare those beans?
>
> Not for example if approaches like i wrote above are a satisfactory
> solution.
>
> ~mck
>
>
Hi guys, I apologise for not subscribing to the dev list before submitting a
pull request, the though had not crossed my mind. It is funny because I did pose
the question on the users mailing list how to achieve what I was after and
directed to look at the source code for the MenuItem.
Anyway, I think the mck's approach would work, however when using `expression`
attributes within `<add-list-attribute>` causes an NPE. I have to be honest that
it's not quite as clean in both the definitions and in the view due to more
nesting in the definition and array indexing in the view as it can't be accessed
by name.
A quite universal solution that would be valuable for many scenarios would be
some sort of tuple support within tiles for paired or triplet values. This would
allow one to add attributes just how mck describes but not need to use indexes
to the attribute in the view, and not have all the nesting vertical problem
within the tiles configs, consider:
<put-list-attribute name="breadcrumbs" cascade="true" inherit="true">
<add-pair-attribute left-value="Orders"
right-expression="/customers/${customer.id}/orders"/>
<add-pair-attribute left-expression="${salesOrder.id}"
right-expression="/customers/${customer.id}/orders/${salesOrder.id}"/>
</put-list-attribute>
vs
<put-list-attribute name="breadcrumbs" cascade="true" inherit="true">
<add-list-attribute>
<add-attribute value="Orders"/>
<add-attribute expression="/customers/${customer.id}/orders"/>
</add-list-attribute>
<add-list-attribute>
<add-attribute expression="${salesOrder.id}"/>
<add-attribute
expression="/customers/${customer.id}/orders/${salesOrder.id}"/>
</add-list-attribute>
</put-list-attribute>
As a final note I think some more example documentation could go a long way.
I would be more than happy to write up any documentation on these sorts of more
interesting uses of tiles, while there's sufficient API and DTD documentation
more example type docs could go a long way. As an example, apart from the DTD
and API documentation I couldn't find any documentation on the use of
add-list-attribute on tiles.apache.org or even a google search.
I'm more than happy to discuss any point further, and very willing to help where
I can. My use of tiles would probably be considered moderate, It's always been
my go to composition choice within spring applications for at least the past 5
years, but as you can tell I don't have an advanced knowledge of tiles.