[T5] BeanEditForm how to add to (decorate) the default renderer of a field?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[T5] BeanEditForm how to add to (decorate) the default renderer of a field?

Michael Capper
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.

How would this be done?

The field in question is a palette magicked in by the AppPropertyEditBlocks.

Greetings from Karlsruhe,
Mike
Reply | Threaded
Open this post in threaded view
|

Re: [T5] BeanEditForm how to add to (decorate) the default renderer of a field?

Howard Lewis Ship
I'm afraid this isn't something the BeanEditor can handle.

You might be able to accomplish this using a local property override
and a PropertyEditor component to "drag in" the default property
editor block

On Wed, Jul 16, 2008 at 4:02 AM, Michael Capper <[hidden email]> 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.
>
> How would this be done?
>
> The field in question is a palette magicked in by the AppPropertyEditBlocks.
>
> Greetings from Karlsruhe,
> Mike
> --
> View this message in context: http://www.nabble.com/-T5--BeanEditForm-how-to-add-to-%28decorate%29-the-default-renderer-of-a-field--tp18485061p18485061.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [T5] BeanEditForm how to add to (decorate) the default renderer of a field?

Michael Capper
Thanks Howard,
pity though.


*some rambling:*
I didn't have enough time to dig into the BeanEditForm/BeanEditor/PropertyEditor thing far enough to unearth the workings of the <parameter ..> thing, otherwise i'd like to have tried overriding the usual parameter with my own parameter so it could take another attribute besides 'name', maybe something like a voluntary boolean 'startgroup' or 'endgroup', and if one of these is set, the PropertyEditor would not be passed the overrides any further but would render normally instead and add a <t:body> before or after its rendering.

Anyway, i wanted to group a few fields in the form.
Well, i w├╝rgedaround the issue by adding some null-fields to the BeanModel, reorder them to fit (startgroup1, field1_1, field1_2, endgroup1, startgroup2,...) and supply those with some appropriate rendering to at least make it look as if the fields were thematically grouped. Unfortunately this produced a lot of boilerplate-code to define all these parameters again, which could not be lessend by a t:loop around the parameters ;)

Till next time,
Michael

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

On Wed, Jul 16, 2008 at 4:02 AM, Michael Capper <mjcapper@avetana.de> wrote:
>
> Hi,
> i want  like
>
> <t:BeanEditForm....>
>  <t:parameter name="firstgroupitem">
>    <hr/>
>    <t:body/>
>  </t:parameter>
>  ...
> </t:BeanEditForm>
>
> Consider the <t:body/> as a placeholder
Reply | Threaded
Open this post in threaded view
|

Re: [T5] BeanEditForm how to add to (decorate) the default renderer of a field?

Howard Lewis Ship
I think the basic pieces of BeanEditForm could be reused to build a
component such as the one you describe.  The BeanEditForm is not
intended as the be-all and end-all of user input; it's supposed to
supply useful scaffolding at the beginning of a project and, for
critical forms with complex layouts, be replaced by a custom set of
components. What I wouldn't want to do is make it address edge cases,
such as this specific  ordering issue, at the expense of making it
useful for beginners, or as a quick placeholder in a rapidly developed
application.  For instance, I wouldn't want there to be some kind of
BeanEditLayoutModel that would have to be supplied to the BeanEditor
(inside the BeanEditForm), unless that could be created easily and
have a good default.

What could be changed would be to have the PropertyEditor component
fire an event before and after each property it renders; this would
give your code the ability to hook in and decorate before and after
the property editor markup is generated.

On Mon, Jul 21, 2008 at 7:28 AM, Michael Capper <[hidden email]> wrote:

>
> Thanks Howard,
> pity though.
>
>
> *some rambling:*
> I didn't have enough time to dig into the
> BeanEditForm/BeanEditor/PropertyEditor thing far enough to unearth the
> workings of the <parameter ..> thing, otherwise i'd like to have tried
> overriding the usual parameter with my own parameter so it could take
> another attribute besides 'name', maybe something like a voluntary boolean
> 'startgroup' or 'endgroup', and if one of these is set, the PropertyEditor
> would not be passed the overrides any further but would render normally
> instead and add a <t:body> before or after its rendering.
>
> Anyway, i wanted to group a few fields in the form.
> Well, i w├╝rgedaround the issue by adding some null-fields to the BeanModel,
> reorder them to fit (startgroup1, field1_1, field1_2, endgroup1,
> startgroup2,...) and supply those with some appropriate rendering to at
> least make it look as if the fields were thematically grouped. Unfortunately
> this produced a lot of boilerplate-code to define all these parameters
> again, which could not be lessend by a t:loop around the parameters ;)
>
> Till next time,
> Michael
>
>
> 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
>>
>> On Wed, Jul 16, 2008 at 4:02 AM, Michael Capper <[hidden email]>
>> wrote:
>>>
>>> Hi,
>>> i want  like
>>>
>>> <t:BeanEditForm....>
>>>  <t:parameter name="firstgroupitem">
>>>    <hr/>
>>>    <t:body/>
>>>  </t:parameter>
>>>  ...
>>> </t:BeanEditForm>
>>>
>>> Consider the <t:body/> as a placeholder
>>
>>
>
> --
> View this message in context: http://www.nabble.com/-T5--BeanEditForm-how-to-add-to-%28decorate%29-the-default-renderer-of-a-field--tp18485061p18569801.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [T5] BeanEditForm and Grid: how to add to (decorate) the default renderer of a field?

Michael Capper
In reply to this post by Howard Lewis Ship
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 <mjcapper@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.
>