tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From JRD <danger_...@hotmail.com>
Subject Re: Iterate through Attributes
Date Tue, 15 Apr 2008 20:04:43 GMT

The begining: I am building an application that has several different
'transactions'.  All transactions collect similar information and all
transactions have the same look and feel.  So transaction 'A' might collect
two addresses and two dates, and transaction 'B' might collect one address,
one text field, and one date.

How a user interacts with a transaction depends both upon the transactions
state and the users security level.  If the transaction is not considered
final and the users security level allows it, the transaction should appear
as a form.  If not the user just sees a read only screen.

For each transaction I have a single JSP (and would like to keep it that



I want to have a view selector jsp that sits between each component and its

tiles-def file:
<definition name=".output_selector" template=".../output_selector.jsp"/>
<definition name=".text" extends=".output_selector">
	<put-attribute name="dataEntry" value=".../data_entry/text.jsp"/>
	<put-attribute name="readOnly"  value=".../read_only/text.jsp"/>
<definition name=".date" extends=".output_selector">
	<put-attribute name="dataEntry" value=".../data_entry/date.jsp"/>
	<put-attribute name="readOnly"  value=".../read_only/date.jsp"/>

Going back to my transaction_b.jsp it would look like
<t:insertDefinition name=".text" >
	<t:putAttribute name="property"  value="votingPercentageAcquired" />
	<t:putAttribute name="labelKey"  value="label.votingPrecentageAcquired"/>
	<t:putAttribute name="size"      value="3"/>
	<t:putAttribute name="maxlength" value="3"/>
<t:insertDefinition name=".date" >
	<t:putAttribute name="property"  value="effectiveDate" />
	<t:putAttribute name="labelKey"  value="label.effectiveDate"/>
	<t:putAttribute name="format"    value="MM/dd/yyyy"/>

This would go to the view selector that would determine the format and then
insert the correct view.  The correct view would need all of the attributes. 
For the text it needs field, property, labelKey, size, & maxlength.  For the
date it needs property, labelKey, and format.

As you can see, the view_selector can not make any assumptions about what
properties to pass along, its job is just to select the view and pass along
everything to it.  Every view that uses it has different attributes.

...select approprate view...
<tiles:insertAttribute name="${approprateView}">
	pass everything along to this view...either one by one or all at once

JRD wrote:
> We are migrating an app from Struts1/Tiles1 to Struts2/Tiles2
> We have a bunch of different transactions types that all collect similar
> data (Addresses, dates, text inputs, etc...).  We use tiles as a view
> controller (among other things).
> So for each thing we want to display we would have a read-only and a
> data-entry display.  The view controller would use state and security to
> determine what view was appropriate, and then pass along all of the
> original data passed in to the correct view.
> In Tiles 1 our view controller looked like this:
> <c:set var="tilesKey" value="org.apache.struts.taglib.tiles.CompContext"/>
> <cw:set var="theTiles" bean="${tilesKey}"/>
> ...select view...
> <tiles:insert definition="${definition}">
> 	<tiles:put name="viewFormat" value="${viewFormat}"/>
> 	<c:forEach items="${theTiles.attributeNames}" var="attribute">
> 		<tiles:put name="${attribute}"><tiles:getAsString
> name="${attribute}"/></tiles:put>
> 	</c:forEach>
> </tiles:insert>
> The view selector can not know what attributes to pass along since each
> thing we want to display has different attributes.  Any idea how to do
> this in Tiles 2?
> Thanks in advance,
> Jonathan

View this message in context: http://www.nabble.com/Iterate-through-Attributes-tp16702610p16707554.html
Sent from the tiles users mailing list archive at Nabble.com.

View raw message