tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rabenda, Clay" <Clay.Rabe...@mtvnmix.com>
Subject RE: Session Attribute in Tiles Definition
Date Tue, 06 Oct 2009 16:23:27 GMT
David,
I'm not sure if there's a way to do exactly what you're asking but I can
suggest another way that I've used.
With a preparer you might do something this:

Put an place-holder string into the tiles configuration like so:

	<put-attribute name="title_page_name" value="Sales
[SALES_RATES_SERVICE_TYPE] Rates" /> </definition>

Wire up a preparer for the definition:

	<definition name="SalesRates_application.layout"
extends="general.logon.layout"
preparer="com.claytonrabenda.awesometitlepreparer">

In the preparer, grab the attribute and replace the string:
	
	String theTitle = (String)
attributeContext.getAttribute("title_page_name").getValue();
      //Do replacement here using session
	attributeContext.putAttribute("title", new Attribute(theTitle));

Hope this helps!
-Clayton Rabenda


-----Original Message-----
From: Smith, David W [mailto:david.w.smith@bankofamerica.com] 
Sent: Tuesday, October 06, 2009 12:12 PM
To: users@tiles.apache.org
Subject: Session Attribute in Tiles Definition

Is it possible to add attributes from the session to the put attribute
of a tiles definition. I would like to do something like...

<definition name="SalesRates_application.layout"
extends="general.logon.layout">
	<put-attribute name="title_page_name" value="Sales
${sessonScope.SALES_RATES_SERVICE_TYPE} Rates" /> </definition>

What do I need to setup to allow the expression language to be able to
parse the session attribute. Can Struts 2 expressions such as
%{#session.SALES_RATES_SERVICE_TYPE} also be used?

The expression language support page on the tiles web site has the
example

<definition name="test.composite.el.definition"
templateExpression="${layout}"
preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer">
      <put-attribute name="title"  value="This is a configured composite
definition."/>
      <put-attribute name="header" value="/header.jsp"/>
      <put-attribute name="body"   expression="${requestScope.body}"/>
</definition>

Where does the templateExpression= and expression= attributes come from?
I don't see them defined in the tiles reference sheet.

David Smith





Mime
View raw message