Re: Marker for required fields on bean editor
Awesome :) Thanks a lot! On Fri, Sep 4, 2009 at 3:04 AM, DH wrote: > I've finished something like that before. > First create a mixin 'FieldDecorator', then need contribute to the > BeanBlockOverrideSource. > Here is the sample code: > 1. > @MixinAfter > public class FieldDecorator { > > �...@injectcontainer > private AbstractField field; > > �...@inject > private ComponentResources resources; > > void cleanupRender(MarkupWriter writer) > { > if (field.isRequired()) { > writer.element("font", "color", "red"); > writer.writeRaw(" * "); > writer.end(); > } > } > > 2. Contribution, override the default edit block in page > PropertyEditBlocks.java. > public static void > contributeBeanBlockOverrideSource(Configuration > configuration) { > configuration.add(new BeanBlockContribution("text", "CustomEditBlocks", > "text", true)); > } > > You need write your own CustomEditBlocks.java and CustomEditBlocks.tml to do > something like PropertyEditBlocks.java and PropertyEditBlocks.tml, then just > put the mixin 'FieldDecorator' there. > > DH > http://www.gaonline.com.cn > > - Original Message - > From: "Juan E. Maya" > To: "Tapestry users" > Sent: Friday, September 04, 2009 1:56 AM > Subject: Re: Marker for required fields on bean editor > > > Sorry Sebastian, i was not clear enough. > I want to change the markup of the label when the field has a required > validator. For example i want to add a CSS class required to the label > of the required field. or i want to add a * next to the label. > > Thanks for ur answer :) > > On Thu, Sep 3, 2009 at 7:40 PM, Sebastian > Hennebrueder wrote: >> Juan E. Maya schrieb: >>> >>> Hi all! >>> >>> Is it possible to mark the required fields inside a beaneditor form as >>> valid? I know i could override the field declaration and put the >>> marker there but i would like to create something more generic. >>> >>> I was thinking that a Mixin may get the beaneditor's form to get all >>> the components in the form, iterate over the validators and add the js >>> or mark to the ones with a required validator but i am not sure how to >>> accomplish this. Is it possible at all? Has anybody done such thing? >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >>> For additional commands, e-mail: users-h...@tapestry.apache.org >>> >>> >> You are aware of @Validate? >> http://tapestry.apache.org/tapestry5/guide/validation.html >> >> >> -- >> Best Regards / Viele Grüße >> >> Sebastian Hennebrueder >> - >> Software Developer and Trainer for Hibernate / Java Persistence >> http://www.laliluna.de >> >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Marker for required fields on bean editor
I've finished something like that before. First create a mixin 'FieldDecorator', then need contribute to the BeanBlockOverrideSource. Here is the sample code: 1. @MixinAfter public class FieldDecorator { @InjectContainer private AbstractField field; @Inject private ComponentResources resources; void cleanupRender(MarkupWriter writer) { if (field.isRequired()) { writer.element("font", "color", "red"); writer.writeRaw(" * "); writer.end(); } } 2. Contribution, override the default edit block in page PropertyEditBlocks.java. public static void contributeBeanBlockOverrideSource(Configuration configuration) { configuration.add(new BeanBlockContribution("text", "CustomEditBlocks", "text", true)); } You need write your own CustomEditBlocks.java and CustomEditBlocks.tml to do something like PropertyEditBlocks.java and PropertyEditBlocks.tml, then just put the mixin 'FieldDecorator' there. DH http://www.gaonline.com.cn - Original Message - From: "Juan E. Maya" To: "Tapestry users" Sent: Friday, September 04, 2009 1:56 AM Subject: Re: Marker for required fields on bean editor Sorry Sebastian, i was not clear enough. I want to change the markup of the label when the field has a required validator. For example i want to add a CSS class required to the label of the required field. or i want to add a * next to the label. Thanks for ur answer :) On Thu, Sep 3, 2009 at 7:40 PM, Sebastian Hennebrueder wrote: > Juan E. Maya schrieb: >> >> Hi all! >> >> Is it possible to mark the required fields inside a beaneditor form as >> valid? I know i could override the field declaration and put the >> marker there but i would like to create something more generic. >> >> I was thinking that a Mixin may get the beaneditor's form to get all >> the components in the form, iterate over the validators and add the js >> or mark to the ones with a required validator but i am not sure how to >> accomplish this. Is it possible at all? Has anybody done such thing? >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > You are aware of @Validate? > http://tapestry.apache.org/tapestry5/guide/validation.html > > > -- > Best Regards / Viele Grüße > > Sebastian Hennebrueder > - > Software Developer and Trainer for Hibernate / Java Persistence > http://www.laliluna.de > > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Marker for required fields on bean editor
Sorry Sebastian, i was not clear enough. I want to change the markup of the label when the field has a required validator. For example i want to add a CSS class required to the label of the required field. or i want to add a * next to the label. Thanks for ur answer :) On Thu, Sep 3, 2009 at 7:40 PM, Sebastian Hennebrueder wrote: > Juan E. Maya schrieb: >> >> Hi all! >> >> Is it possible to mark the required fields inside a beaneditor form as >> valid? I know i could override the field declaration and put the >> marker there but i would like to create something more generic. >> >> I was thinking that a Mixin may get the beaneditor's form to get all >> the components in the form, iterate over the validators and add the js >> or mark to the ones with a required validator but i am not sure how to >> accomplish this. Is it possible at all? Has anybody done such thing? >> >> - >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > You are aware of @Validate? > http://tapestry.apache.org/tapestry5/guide/validation.html > > > -- > Best Regards / Viele Grüße > > Sebastian Hennebrueder > - > Software Developer and Trainer for Hibernate / Java Persistence > http://www.laliluna.de > > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Marker for required fields on bean editor
Juan E. Maya schrieb: Hi all! Is it possible to mark the required fields inside a beaneditor form as valid? I know i could override the field declaration and put the marker there but i would like to create something more generic. I was thinking that a Mixin may get the beaneditor's form to get all the components in the form, iterate over the validators and add the js or mark to the ones with a required validator but i am not sure how to accomplish this. Is it possible at all? Has anybody done such thing? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org You are aware of @Validate? http://tapestry.apache.org/tapestry5/guide/validation.html -- Best Regards / Viele Grüße Sebastian Hennebrueder - Software Developer and Trainer for Hibernate / Java Persistence http://www.laliluna.de - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Marker for required fields on bean editor
Hi all! Is it possible to mark the required fields inside a beaneditor form as valid? I know i could override the field declaration and put the marker there but i would like to create something more generic. I was thinking that a Mixin may get the beaneditor's form to get all the components in the form, iterate over the validators and add the js or mark to the ones with a required validator but i am not sure how to accomplish this. Is it possible at all? Has anybody done such thing? - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org