You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tiles.apache.org by Antonio Petrelli <an...@gmail.com> on 2007/06/18 19:38:35 UTC

Pluggable attribute evaluation (WAS: Adding new attribute type....)

2007/6/18, Pawel Kozlowski <pk...@amadeus.com>:
> What I want to do is a new attribute type of a "WebWork" (or Struts2)
> type. This is basically the same as putting in a Tile attribute a JSP that
> is executing a WebWork action (with the provided action tag)

It seems pretty interesting, but please follow this discussion in
Tiles Developers mailing list.
In fact, I was thinking about a pluggable "attribute renderer" that
takes an attribute as an input and renders it. The particular use case
was for evaluating objects with EL.
Probably a "chain" implementation (one element of the chain evaluates
Struts 2 actions, the other EL expressions, the last is the default
evaluator i.e. the one with the "switch") could be useful and,
possibly, allow configuration of this chain by plugins (e.g. Struts 2
plugin).
Note that, anyway, such a major change would be done only in Tiles 2.1.

> A Tile:
>
> <definition name="app.page.home" extends="core.page" >
>         <put-attribute name="title" value="Home"/>
>         <put-attribute name="body" value="..."/>
>         <put-attribute name="dynamicFooter" value="DynamicFooter.jsp"/>
> </definition>
>
> the DynamicFooter.jsp:
>
> <ww:action name=" DynamicFooter" executeResult="true" />
>
> By writing such an attribute I want to avoid creation of those small,
> intermediate "action JSPs". At the same time it would allow me to build
> pages from "true" components, having their own controllers. For me this is
> a legitimate use case - what do you think? Is there a better way to
> achieve this?


Just curious, what does prevent you from using the
"/DynamicFooter.action" syntax?

>
> Of course changing BasicTilesContainer would be possible (the code is
> really clean and readable) but hey, I would like to benefit from future
> releases of Tiles2 and not to start my own branch ;-)

Using your own Container does not mean branching :-)

> PS Sorry for not linking this post with a thread - from now on I'll be a
> good citizen - I've subscribed to the list :-)

And now you have to subscribe to another one :-)

Ciao
Antonio

Re: Pluggable attribute evaluation (WAS: Adding new attribute type....)

Posted by Pawel Kozlowski <pk...@amadeus.com>.
Hi Antonio and All on this list, 

Once again, thnx for your response?. 

"Antonio Petrelli" <an...@gmail.com> wrote on 18/06/2007 
19:38:35:

> It seems pretty interesting, but please follow this discussion in
> Tiles Developers mailing list.
> In fact, I was thinking about a pluggable "attribute renderer" that
> takes an attribute as an input and renders it. The particular use case
> was for evaluating objects with EL.
> Probably a "chain" implementation (one element of the chain evaluates
> Struts 2 actions, the other EL expressions, the last is the default
> evaluator i.e. the one with the "switch") could be useful and,
> possibly, allow configuration of this chain by plugins (e.g. Struts 2
> plugin).

EL support would be definitely a big plus! 

As for design: pluggable renderers sound like a good idea. Are you 
thinking of registering those renderers in a container? And then, while 
rendering an attribute, looking for a proper renderer? This should work 
fine, I guess. I only wonder what we should do with the enum for an 
attribute type. Drop it altogether? 

> Note that, anyway, such a major change would be done only in Tiles 2.1.

I'm not suprised to hear this ;-)
 
 
> Just curious, what does prevent you from using the
> "/DynamicFooter.action" syntax?

3 reasons for this: 
- I need to do some custom processing before dispatching to an action 
(pass some parameters etc. - maybe with EL support it would be no longer 
necessary);
- I also need to add other attr types,
- I couldn't make "/DynamicFooter.action" syntax work with Struts 2.0.8 + 
Tiles 2.0.3. I've spend some time debugging the code and it looks like 
this syntax would be equivalent to doing <jsp:include flush="true" 
page="/DynamicFooter.action" / in a JSP. In Tomcat it gives me "The 
requested resource (/[context name]/DynamicFooter.action) is not available
" error.

So, I would be more then happy to discuss a design when we are able to add 
a new attribute type without too much pain?

Cheers,
Pawel