String.format("model.object.%s", id))); On Wed, Nov 26, 2008 at 12:57 AM, Ned Collyer <[EMAIL PROTECTED]> wrote: > > I'm trying to throw together some components for easily creating accessible > forms. > > I'm a fair bit along - just need some assistance with how to structure the > class for use with CompoundPropertyModels. > > I want to be able to do the following: > > Form form = new Form("form", new CompoundPropertyModel(new User()); > form.add(new LabelledTextField("name")) > > But I'm having difficulty setting the property model against the textfield > inside my LabelledTextField. > > I can retrieve the values just fine, and they are set on the object from the > forms CPM. > > I am using a fragment so that markup can be edited in a single place for all > "labelled" form fields. And different markup providers or variants can be > used if any edge cases occur for any projects. > > The form fields can also used as easily as any other form fields in wicket - > this is a different approach from wicketopia - which I've had a good dig > through. > > I've gotta be close! > > > /* the class itself */ > > private final FormComponentLabel label; > private final Label labelText; > private final TextField<T> editor; > private Fragment componentFragment; > > public class LabelledTextField<T> extends FormComponentPanel<T> { > > public LabelledTextField(String id) { > super(id); > > componentFragment = new Fragment(COMPONENT_ID, "textField", this); > editor = new TextField<T>("editor", new PropertyModel(this, > String.format("model.%s", id))); > label = new FormComponentLabel("label", editor); > labelText = new Label("labelText", "TBA"); > label.add(labelText); > > componentFragment.add(editor); > componentFragment.add(label); > > add(componentFragment); > > setRenderBodyOnly(true); > } > > protected void convertInput() { > setConvertedInput(editor.getConvertedInput()); > } > > public String getInput() { > return editor.getInput(); > } > } > -- > View this message in context: > http://www.nabble.com/Using-CompoundPropertyModel-with-FormComponentPanel-tp20697019p20697019.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]