struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Affan Qureshi" <quere...@etilize.com>
Subject [Tiles] Design - Overriding <putList> items
Date Mon, 10 Mar 2003 04:40:14 GMT
I have divided the modules(logical) in my application in a Tab layout. I
want to show different pages under the same tab at various points in the
application. It means the putList items change all the time. If I want to
extend and override the values inside the putList tags I have to write the
whole putList tag again in the extended definition. Is this right or is
there a better way?

I have created a bean in which I keep values for links to display in each
tab and modify them at runtime in my Action classes. I put that bean in
session and copy its properties to the TilesContext in the controllerClass
actions. The problem is that this design is not very easy to maintain and
enhance. Also I get the values mixed up in the session which makes the user
go to a wrong page sometimes. And the layout code is all over the place
instead of a single, configurable one (like the XML file).

Is this the right design I have? Any suggestions/solutions?

Thanks a lot,
Affan

PS
My Tiles Code below:

This is my basic/default definition:

<definition name="index.page" path="/webpages/layouts/tabsLayout.jsp"
controllerClass="com.etilize.cms.web.actions.LayoutProcessorAction">
    <put name="title" value="MyAppName"/>
    <put name="header" value="/webpages/header.jsp"/>
    <put name="footer" value="/webpages/footer.jsp"/>
    <put name="selectedIndex" value="0"/>
    <put name="parameterName" value="selected"/>
    <putList name="tabList">
        <item value="Home" link="/webpages/home.jsp"
classtype="org.apache.struts.tiles.beans.SimpleMenuItem"/>
        ................
        <item value="Taxonomy" link="/webpages/template.jsp"
classtype="org.apache.struts.tiles.beans.SimpleMenuItem"/>
        ..................
        <item value="Search" link="/webpages/search.jsp"
classtype="org.apache.struts.tiles.beans.SimpleMenuItem"/>
    </putList>
</definition>

In actions i have the following code to set the values in the session bean:
        LayoutSettings settings =
(LayoutSettings)req.getSession(true).getAttribute(WebAppConstants.TAB_LAYOUT
_SETTINGS);
        List tabList = settings.getTabList();
        SimpleMenuItem searchTab = (SimpleMenuItem)tabList.get(3);
        searchTab.setLink(returnLink);
        tabList.set(3,searchTab);
        settings.setTabList(tabList);

req.getSession(true).setAttribute(WebAppConstants.TAB_LAYOUT_SETTINGS,settin
gs);


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Mime
View raw message