The wicketopia project has a mechanism for automagically creating labels for bean properties.
http://wicketopia.sourceforge.net Take a look at PropertyLabel and PropertyLabelModel (there should be test cases) On Sun, Nov 23, 2008 at 7:56 PM, Ned Collyer <[EMAIL PROTECTED]> wrote: > > I'm looking for suggestions on various ways of handling form layout - > specifically auto generating labels for form components, and the associated > markup surrounding the form fields. > > I've currently got a system in place that allows you to add the fields very > simply, and then uses a technique similar to "forms with flair" > http://londonwicket.org/content/LondonWicket-FormsWithFlair.pdf to add the > labels, error messages and standard markup. > > What this gives us is a means for developers to have accessible standards > compliant forms (all labelled and linked) without each dev having to > manually add the appropriate markup structure. > > Eg, > Java: > Form form = new Form("form", new PersonModel()); > form.add(new TextField("name")); > form.add(new CheckBoxMultipleChoice("breakfasts", > breakfastList).setRequired(true)); > form.visitFormComponents(new MyLabelMakerOfAwesome()); > add(form); > > Wicket Html: > <form wicket:id="form"> > <input type="text" wicket:id="name" /> > <wicket:container wicket:id="breakfasts" /> > </form> > > Actual output > <form> > <div class="form-field"> > <label for="name">Name</label> > <input type="text" name="name" value="" id="name"/> > </div> > <div class="form-field"> > <fieldset> > <legend>Breakfasts <em class="required">*</em></legend> > <ul> > <li><label>Egg <input type="checkbox" > name="breakfasts" > /></label></li> > <li><label>Bacon <input type="checkbox" > name="breakfasts" > /></label></li> > <li><label>Toast <input type="checkbox" > name="breakfasts" > /></label></li> > </ul> > </fieldset> > </div> > </form> > > Manual markup of each form is a common point of failure, especially with > hundreds of fields and tens of developers. > > This works well in MOST circumstances... except when you want to work > outside of the default. > > I am looking for a solution that will allow me to: > a/ embed 3rd party components without them being effected (eg, the > calendar/datepicker controls). > b/ be able to update the LABELS only with Ajax - without replacing the > field. > c/ easily exclude fields from the default. > d/ be able to add new fields to the form with Ajax (currently fields added > like this are not effected by the visitor). > > I'd love some ideas re: the best way of achieving this. I'm not asking for > code :) just ideas. > > I think it could be very useful - especially if the markup is easily changed > to meet individual project requirements, and definitely gives a more DRY > approach to forms. > > ps, i wrote this all in a simple text editor so if there are any flaws, I > hope the message is still communicated ;) > -- > View this message in context: > http://www.nabble.com/Labelling-standard-layout-for-form-components.-tp20653187p20653187.html > Sent from the Wicket - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
