You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Capper <mj...@avetana.de> on 2009/06/16 10:51:57 UTC
Re: [T5] BeanEditForm and Grid: how to add to (decorate) the
default renderer of a field?
Done it like this (in a grid, but that's basically the same):
implemented our own GridCell (copy-pasted all of AbstractPropertyEditor and
original GridCell for visibility reasons), but changed these two methods:
Object beginRender(MarkupWriter writer)
{
Object before = renderPropertyValue(writer, getPropertyModel().getId()
+ "BeforeCell", false);
Object main = renderPropertyValue(writer, getPropertyModel().getId()
+ "Cell", true);
Object after = renderPropertyValue(writer, getPropertyModel().getId()
+ "AfterCell", false);
if (main instanceof BlockImpl)
{
BlockImpl bi = (BlockImpl) main;
BlockImpl result = new BlockImpl(bi.getLocation(),
"multiblock");
if (before != null && before instanceof BlockImpl)
{
result.addToBody((BlockImpl) before);
}
result.addToBody(bi);
if (after != null && after instanceof BlockImpl)
{
result.addToBody((BlockImpl) after);
}
return result;
}
return main;
}
protected Object renderPropertyValue(MarkupWriter writer,
String overrideBlockId, boolean showdefault)
{
Block override = overrides.getOverrideBlock(overrideBlockId);
String datatype = model.getDataType();
if (override != null)
{
Debug.debug("overrideBlock=" + override);
Block ov = override;
return override;
}
if (showdefault)
{
[snip...]
// Don't render anything else
return false;
}
return null;
}
where formerly I'd write
<t:parameter name="lastloggedinBeforeCell">
i'm your decoration ${originalValue}
</t:parameter>
in the Component Template now I use
<t:parameter name="lastloggedinBeforeCell">
i'm your decoration
</t:parameter>
I have yet to "wrap" an Actionlink around it, I probably have to split the
ActionLink-Component into two, one before and one after the main BlockImpl,
opening and closing the Link respectively.
Howard Lewis Ship wrote:
>
> You might be able to accomplish this using a local property override
> and a PropertyEditor component to "drag in" the default property
> editor block.
>
> Maybe this will help somebody sometime :)
>
> Mike
>
> On Wed, Jul 16, 2008 at 4:02 AM, Michael Capper <mj...@avetana.de>
> wrote:
>>
>> Hi,
>> i want to decorate some fields of a BeanEditForm in use. With decorate i
>> mean keep the old but wrap some html around it (e.g. a <hr/>, or wrap it
>> in
>> a ) like
>>
>> <t:BeanEditForm....>
>> <t:parameter name="firstgroupitem">
>> <hr/>
>> <t:body/>
>> </t:parameter>
>> ...
>> </t:BeanEditForm>
>>
>> Consider the <t:body/> as a placeholder for whatever would render the
>> original data.
>>
>
--
View this message in context: http://www.nabble.com/-T5--BeanEditForm-how-to-add-to-%28decorate%29-the-default-renderer-of-a-field--tp18485061p24050191.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org