You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by Antonio Petrelli <an...@gmail.com> on 2009/02/01 23:37:20 UTC

Re: How to include a SimpleMenuItem bean in tiles:addAttribute in struts2

2009/2/1 Ignacio de Córdoba <ic...@skios.es>:
> You mean a preparer for my path/breadcrums Tile? The preparer whon't have
> information about path as everything related to breadcrums/path depends on
> the Tiles configuration. I so don't figure out what to "prepare" in the
> preparer.

I meant that the code that you posted before, that you can find below,
can easily be written using a preparer for the definition.

The code was:

<tiles:insertDefinition name="breadcrumsTile">
       <tiles:putListAttribute name="breadcrums">
               <jsp:useBean id="item"
class="org.apache.tiles.beans.SimpleMenuItem"
scope="page"/>
                       <c:set var='folderName'><s:property
value="#folderName"/></c:set>
                       <jsp:setProperty  name="item" property="link"
value="Actions_folder.action?folderName=${folderName}"/>
                       <jsp:setProperty name="item" property="value"
value="${folderName}"/>
                       <tiles:addAttribute value="${item}"/>
       </tiles:putListAttribute>
</tiles:insertDefinition>

You can change it into:

<tiles:insertDefinition name="breadcrumsTile" preparer="my.package.MyPreparer">
</tiles:insertDefinition>

And create the "MyPreparer" class that uses the AttributeContext to
fill the list attribute:

ListAttribute listAttribute = new ListAttribute();
List<Attribute> attributes= new ArrayList<Attribute>();
// Code to fill the list
listAttribute.setValue(attributes);
attributeContext.putAttribute("breadcrums", listAttribute);

HTH
Antonio

Re: How to include a SimpleMenuItem bean in tiles:addAttribute in struts2

Posted by Antonio Petrelli <an...@gmail.com>.
2009/2/3 Antonio Petrelli <an...@gmail.com>:
> 2009/2/3 Ignacio de Córdoba <ic...@skios.es>:
>>
>> my problem if coding is that I'd have to make a preparer for every tile, or
>> a complex conditions scenario in java code to make it include different
>> breadcrums in each tile. Anyway, my main matter is that I compile my actions
>> and reuse them in different projects. Coding breadcrums/path there means I
>> cannot change action paths in different projects. I need to embeed path
>> information in the jsp page it self because I only know the path of the
>> action of a project right there; in the page.
>
> I think that, since you are using Struts 2, you should change
> technology completely. There is a Struts 2 breadcrumbs plugin that you
> can use:
> http://cwiki.apache.org/S2PLUGINS/breadcrumbs-plugin.html

Forget it (and forgive me :-) ), the web page that is linked there
give an HTTP 500.

Antonio

Re: How to include a SimpleMenuItem bean in tiles:addAttribute in struts2

Posted by Antonio Petrelli <an...@gmail.com>.
2009/2/3 Ignacio de Córdoba <ic...@skios.es>:
>
> my problem if coding is that I'd have to make a preparer for every tile, or
> a complex conditions scenario in java code to make it include different
> breadcrums in each tile. Anyway, my main matter is that I compile my actions
> and reuse them in different projects. Coding breadcrums/path there means I
> cannot change action paths in different projects. I need to embeed path
> information in the jsp page it self because I only know the path of the
> action of a project right there; in the page.

I think that, since you are using Struts 2, you should change
technology completely. There is a Struts 2 breadcrumbs plugin that you
can use:
http://cwiki.apache.org/S2PLUGINS/breadcrumbs-plugin.html

Antonio

Re: How to include a SimpleMenuItem bean in tiles:addAttribute in struts2

Posted by Ignacio de Córdoba <ic...@skios.es>.
Thanks for your advice Antonio,
my problem if coding is that I'd have to make a preparer for every tile, or
a complex conditions scenario in java code to make it include different
breadcrums in each tile. Anyway, my main matter is that I compile my actions
and reuse them in different projects. Coding breadcrums/path there means I
cannot change action paths in different projects. I need to embeed path
information in the jsp page it self because I only know the path of the
action of a project right there; in the page.
After developing more Tiles these days I am hating this "duplicated" EL+OGNL
environment where standard EL is old and too simple, with no interest from
SUN to upgrade it (How old is JSTL 1.1 ¿4 years without any change?) while
OGNL is not directly supported in pages (can't just write %{shatever} as we
can ${}).

Ignacio
-- 
View this message in context: http://www.nabble.com/How-to-include-a-SimpleMenuItem-bean-in-tiles%3AaddAttribute-in-struts2-tp21739816p21809271.html
Sent from the tiles users mailing list archive at Nabble.com.