Re: Using CompoundPropertyModel with FormComponentPanel
I'm not sure how to get the textfield editor working on the property name of the user object - I am aware the CPM is trying to look at the id editor which is wrong :). -- View this message in context: http://www.nabble.com/Using-CompoundPropertyModel-with-FormComponentPanel-tp20697019p20698456.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]
Re: Using CompoundPropertyModel with FormComponentPanel
Hi Ned you can call bind on the compound property model.. labelText = new Label(labelText, CPM.bind(propertyname)); You can also do this for your property models btw... Ned Collyer 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 TextFieldT editor; private Fragment componentFragment; public class LabelledTextFieldT extends FormComponentPanelT { public LabelledTextField(String id) { super(id); componentFragment = new Fragment(COMPONENT_ID, textField, this); editor = new TextFieldT(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(); } } -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using CompoundPropertyModel with FormComponentPanel
I'm going to be sourcing the labelText from a properties file relatve to the class of the modelObject (in this case it will be the User - eg, user.properties). If I use the binding, then I need to have scope to the CPM in java world... within the LabelledTextField - which is a shame, because it just makes it less convenient to use like other regular form components where you do not have to pass in the model if the form has CPM (eg, standard TextField) Nino.Martinez wrote: Hi Ned you can call bind on the compound property model.. labelText = new Label(labelText, CPM.bind(propertyname)); You can also do this for your property models btw... -- View this message in context: http://www.nabble.com/Using-CompoundPropertyModel-with-FormComponentPanel-tp20697019p20699724.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]
Re: Using CompoundPropertyModel with FormComponentPanel
ahhh, didnt catch that you were doing that.. Ned Collyer wrote: I'm going to be sourcing the labelText from a properties file relatve to the class of the modelObject (in this case it will be the User - eg, user.properties). If I use the binding, then I need to have scope to the CPM in java world... within the LabelledTextField - which is a shame, because it just makes it less convenient to use like other regular form components where you do not have to pass in the model if the form has CPM (eg, standard TextField) Nino.Martinez wrote: Hi Ned you can call bind on the compound property model.. labelText = new Label(labelText, CPM.bind(propertyname)); You can also do this for your property models btw... -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using CompoundPropertyModel with FormComponentPanel
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 TextFieldT editor; private Fragment componentFragment; public class LabelledTextFieldT extends FormComponentPanelT { public LabelledTextField(String id) { super(id); componentFragment = new Fragment(COMPONENT_ID, textField, this); editor = new TextFieldT(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]
Re: Using CompoundPropertyModel with FormComponentPanel
Bupbow. - that Yields an exception because the FormComponentPanels model object is of type String - not user. editor = new TextFieldT(editor, new PropertyModelT(this, String.format(model.object.%s, id))); org.apache.wicket.WicketRuntimeException: No get method defined for class: class java.lang.String expression: name Rgds Ned igor.vaynberg wrote: String.format(model.object.%s, id))); -- View this message in context: http://www.nabble.com/Using-CompoundPropertyModel-with-FormComponentPanel-tp20697019p20709911.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]
Re: Using CompoundPropertyModel with FormComponentPanel
then justmodel.object will do :) -igor On Wed, Nov 26, 2008 at 2:08 PM, Ned Collyer [EMAIL PROTECTED] wrote: Bupbow. - that Yields an exception because the FormComponentPanels model object is of type String - not user. editor = new TextFieldT(editor, new PropertyModelT(this, String.format(model.object.%s, id))); org.apache.wicket.WicketRuntimeException: No get method defined for class: class java.lang.String expression: name Rgds Ned igor.vaynberg wrote: String.format(model.object.%s, id))); -- View this message in context: http://www.nabble.com/Using-CompoundPropertyModel-with-FormComponentPanel-tp20697019p20709911.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]
Re: Using CompoundPropertyModel with FormComponentPanel
FYI, you are awesome. Always obvious what the problem is after its fixed hey ;) igor.vaynberg wrote: then justmodel.object will do :) -igor -- View this message in context: http://www.nabble.com/Using-CompoundPropertyModel-with-FormComponentPanel-tp20697019p20710669.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]