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 Wed, 16 Apr 2008 14:58:14 GMT

I don't really see it that way.  To me this is the exact intention of Tiles. 
>From my perspective you have two ways of building a UI that has both
dataEntry & readOnly views of the same data.  You can have struts make the
call which one to show or you can leave it to Tiles.  I think the tiles
approach is far superior.  You only have to build and maintain one page for
each object.  The objects in that page are basically abstracted into sub
tiles which guarantees a uniform look across the system.  If you need to
make a change you make it in exactly one place.  All of this really adds up
when you have a lot of these objects in your system.

I was able to get what I wanted by making my own tag.  I'm not happy doing
it as now I need to be careful with Tiles if I want to upgrade but not
having this feature is sort of a show-stopper. 

public class TilesAttributesTag extends AttributeTagSupport {

	private String var = null;
	public String getVar() { return var; }
	public void setVar(String var) { this.var = var; }

	public void execute() throws JspException, IOException {
		Map<String, String> names = new HashMap<String, String>();
		for (Iterator i = attributeContext.getAttributeNames(); i.hasNext();) {
			String name = (String) i.next();
			Attribute attr = attributeContext.getAttribute(name);
			names.put(name, attr.getValue().toString());
		pageContext.setAttribute(getVar(), names);
	public void release() {
		var = null;

and then my view selector

<e:attributeNames var="attributes"/>
<t:insertAttribute name="${format}">
	<c:forEach items="${attributes}" var="attribute">
		<t:putAttribute name="${attribute.key}" value="${attribute.value}"/>

I do think this functionality should be offered out of the box.  I read that
you were working on cascading properties which sounds like it would solve my
problem depending on the implementation.  If you just took everything out of
the parents attributeContext and put it into the new attributeContext it
should be ok.

Let me know what you think,

Antonio Petrelli-3 wrote:
> 2008/4/15, JRD <danger_jon@hotmail.com>:
>> <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"/>
>> </t:insertDefinition>
> I think you've gone too far the intention of Tiles: it seems like a job
> for
> a custom component of Struts 2, or even a normal component.
> Antonio

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

View raw message