|
View:
New views
12 Messages
—
Rating Filter:
Alert me
|
|
|
CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersHi,
I have a question regarding the use of RadioChoice and ChoiceRenderer's in conjunction with CompoundPropertyModel. I'm new to Wicket (but already a convinced user ;) ), so maybe my approach on this one is not at all as it should be... Any comments are welcome ! I'll get into details. Let's say I have a class in my domain model named Person. This entity has a property named 'deptId' of type String. The Person entity is the backing for a CompundPropertyModel applied to the whole form. The 'deptId' field is inputted by the user, let's say, by means of a RadioChoice (I guess it makes no difference from a DropDownChoice taking into account the point of the question). The choice list for the RadioChoice component is a List made up of DTO objects with properties "id" and "description". To ensure proper rendering of labels, I use a suitable ChoiceRenderer. Now, problems come when the 'deptId' property has a value in the Person entity used in the CompoundPropertyModel. I get an error saying that class String does not have any property called 'id' (I suppose this error comes from having a ModelObject of type String and also having a ChoiceRenderer refering to 'id' property). I'll provide some sample code: markup ------------- ... <form wicket:id="form"> ... <span valign="top" wicket:id="deptId"></span> ... </form> ... Java ------------- ... List<SimpleElementDTO> choices = contextData.getChoices(); Person p = new Person(...); Form f = new Form("form"){...}; f.setModel(new CompoundPropertyModel(p)); ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new ChoiceRenderer("id", "description")); f.add(cr); ... I suppose the 'normal' way of doing things would be providing a custom Model to 'cr', but I'd like to know if there is a possibility to achieve this point still using CompoundPropertyModel... The stack trace I get is the following: WicketMessage: No get method defined for class: class java.lang.String expression: id Root cause: org.apache.wicket.WicketRuntimeException: No get method defined for class: class java.lang.String expression: id at org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) at org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) at org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) at org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) at org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) at org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) at org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) at org.apache.wicket.Component.renderComponent(Component.java:2480) at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) at org.apache.wicket.Component.render(Component.java:2317) at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) ... |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersHi Xavier,
>I suppose this error comes from having a ModelObject of type >String and also having a ChoiceRenderer refering to 'id' property your choice is working on SimpleElementDTOs while your Person class has a String property - this cannot work. Ideally you would just set a Department instance into your Person objects, but what you're trying to do can only be accomplished with a custom model. Sven Xavier López wrote: > Hi, > > I have a question regarding the use of RadioChoice and ChoiceRenderer's in > conjunction with CompoundPropertyModel. I'm new to Wicket (but already a > convinced user ;) ), so maybe my approach on this one is not at all as it > should be... Any comments are welcome ! > > I'll get into details. Let's say I have a class in my domain model named > Person. This entity has a property named 'deptId' of type String. The Person > entity is the backing for a CompundPropertyModel applied to the whole form. > The 'deptId' field is inputted by the user, let's say, by means of a > RadioChoice (I guess it makes no difference from a DropDownChoice taking > into account the point of the question). The choice list for the RadioChoice > component is a List made up of DTO objects with properties "id" and > "description". To ensure proper rendering of labels, I use a suitable > ChoiceRenderer. > > Now, problems come when the 'deptId' property has a value in the Person > entity used in the CompoundPropertyModel. I get an error saying that class > String does not have any property called 'id' (I suppose this error comes > from having a ModelObject of type String and also having a ChoiceRenderer > refering to 'id' property). > > I'll provide some sample code: > > markup > ------------- > ... > <form wicket:id="form"> > ... > <span valign="top" wicket:id="deptId"></span> > ... > </form> > ... > > Java > ------------- > > ... > List<SimpleElementDTO> choices = contextData.getChoices(); > Person p = new Person(...); > Form f = new Form("form"){...}; > f.setModel(new CompoundPropertyModel(p)); > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > ChoiceRenderer("id", "description")); > f.add(cr); > ... > > > I suppose the 'normal' way of doing things would be providing a custom Model > to 'cr', but I'd like to know if there is a possibility to achieve this > point still using CompoundPropertyModel... > > The stack trace I get is the following: > > WicketMessage: No get method defined for class: class java.lang.String > expression: id > Root cause: > org.apache.wicket.WicketRuntimeException: No get method defined for class: > class java.lang.String expression: id > at > org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) > at > org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) > at > org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) > at > org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) > at > org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) > at > org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) > at > org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) > at org.apache.wicket.Component.renderComponent(Component.java:2480) > at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) > at org.apache.wicket.Component.render(Component.java:2317) > at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) > ... > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersHi Sven, he stell can write some specialized render... but I think the best
way is you have your depid property of type Department. Than all this thread would not have started :) class YourCustomRender { @Override public String getIdValue(Object object, int index) { if (object instanceof DTO) { return ((DTO)object).getDeptId() } else { return (String)object;//already is the depid string } } @Override public Object getDisplayValue(Object object) { if (object instanceof DTO) { return ((DTO)object).getDescription(); } else { return contextData.getDTOBasedOnDepid(object); } } } On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@...> wrote: > Hi, > > I have a question regarding the use of RadioChoice and ChoiceRenderer's in > conjunction with CompoundPropertyModel. I'm new to Wicket (but already a > convinced user ;) ), so maybe my approach on this one is not at all as it > should be... Any comments are welcome ! > > I'll get into details. Let's say I have a class in my domain model named > Person. This entity has a property named 'deptId' of type String. The > Person > entity is the backing for a CompundPropertyModel applied to the whole form. > The 'deptId' field is inputted by the user, let's say, by means of a > RadioChoice (I guess it makes no difference from a DropDownChoice taking > into account the point of the question). The choice list for the > RadioChoice > component is a List made up of DTO objects with properties "id" and > "description". To ensure proper rendering of labels, I use a suitable > ChoiceRenderer. > > Now, problems come when the 'deptId' property has a value in the Person > entity used in the CompoundPropertyModel. I get an error saying that class > String does not have any property called 'id' (I suppose this error comes > from having a ModelObject of type String and also having a ChoiceRenderer > refering to 'id' property). > > I'll provide some sample code: > > markup > ------------- > ... > <form wicket:id="form"> > ... > <span valign="top" wicket:id="deptId"></span> > ... > </form> > ... > > Java > ------------- > > ... > List<SimpleElementDTO> choices = contextData.getChoices(); > Person p = new Person(...); > Form f = new Form("form"){...}; > f.setModel(new CompoundPropertyModel(p)); > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > ChoiceRenderer("id", "description")); > f.add(cr); > ... > > > I suppose the 'normal' way of doing things would be providing a custom > Model > to 'cr', but I'd like to know if there is a possibility to achieve this > point still using CompoundPropertyModel... > > The stack trace I get is the following: > > WicketMessage: No get method defined for class: class java.lang.String > expression: id > Root cause: > org.apache.wicket.WicketRuntimeException: No get method defined for class: > class java.lang.String expression: id > at > > org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) > at > > org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) > at > > org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) > at > > org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) > at > > org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) > at > > org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) > at > > org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) > at org.apache.wicket.Component.renderComponent(Component.java:2480) > at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) > at org.apache.wicket.Component.render(Component.java:2317) > at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) > ... > -- Pedro Henrique Oliveira dos Santos |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersHi Pedro,
with your condition inside the renderer you've beaten me by originality ;). But I doubt that the choice will be able to store the selected DTO in the entity's String property. Sven Pedro Santos wrote: > Hi Sven, he stell can write some specialized render... but I think the best > way is you have your depid property of type Department. Than all this thread > would not have started :) > > class YourCustomRender > { > @Override > public String getIdValue(Object object, int index) > { > if (object instanceof DTO) > { > return ((DTO)object).getDeptId() > } > else > { > return (String)object;//already is the depid string > } > } > > @Override > public Object getDisplayValue(Object object) > { > if (object instanceof DTO) > { > return ((DTO)object).getDescription(); > } > else > { > return contextData.getDTOBasedOnDepid(object); > } > } > } > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@...> wrote: > > >> Hi, >> >> I have a question regarding the use of RadioChoice and ChoiceRenderer's in >> conjunction with CompoundPropertyModel. I'm new to Wicket (but already a >> convinced user ;) ), so maybe my approach on this one is not at all as it >> should be... Any comments are welcome ! >> >> I'll get into details. Let's say I have a class in my domain model named >> Person. This entity has a property named 'deptId' of type String. The >> Person >> entity is the backing for a CompundPropertyModel applied to the whole form. >> The 'deptId' field is inputted by the user, let's say, by means of a >> RadioChoice (I guess it makes no difference from a DropDownChoice taking >> into account the point of the question). The choice list for the >> RadioChoice >> component is a List made up of DTO objects with properties "id" and >> "description". To ensure proper rendering of labels, I use a suitable >> ChoiceRenderer. >> >> Now, problems come when the 'deptId' property has a value in the Person >> entity used in the CompoundPropertyModel. I get an error saying that class >> String does not have any property called 'id' (I suppose this error comes >> from having a ModelObject of type String and also having a ChoiceRenderer >> refering to 'id' property). >> >> I'll provide some sample code: >> >> markup >> ------------- >> ... >> <form wicket:id="form"> >> ... >> <span valign="top" wicket:id="deptId"></span> >> ... >> </form> >> ... >> >> Java >> ------------- >> >> ... >> List<SimpleElementDTO> choices = contextData.getChoices(); >> Person p = new Person(...); >> Form f = new Form("form"){...}; >> f.setModel(new CompoundPropertyModel(p)); >> ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new >> ChoiceRenderer("id", "description")); >> f.add(cr); >> ... >> >> >> I suppose the 'normal' way of doing things would be providing a custom >> Model >> to 'cr', but I'd like to know if there is a possibility to achieve this >> point still using CompoundPropertyModel... >> >> The stack trace I get is the following: >> >> WicketMessage: No get method defined for class: class java.lang.String >> expression: id >> Root cause: >> org.apache.wicket.WicketRuntimeException: No get method defined for class: >> class java.lang.String expression: id >> at >> >> org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) >> at >> >> org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) >> at >> >> org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) >> at >> >> org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) >> at >> >> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) >> at >> >> org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) >> at >> >> org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) >> at org.apache.wicket.Component.renderComponent(Component.java:2480) >> at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) >> at org.apache.wicket.Component.render(Component.java:2317) >> at org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) >> ... >> >> > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersHi Sven, Pedro,
Thanks both for your quick reply. Ideally you would just set a Department instance into your Person objects the best way is you have your depid property of type Department This was the first approach to take into account, but the idea was discarded in benefit of SimpleElementDTO, in order to provide only the necessary information to Wicket Models, with the intention of not wasting any memory on PageMaps due to Department object serializations... Also, this SimpleElementDTO would be reusable throughout the whole application when it's about Radio and DropDown Choices... write some specialized render > This kinda 'dirty-fix' idea was already crawling in my mind, trying to come out someway. Thanks for providing a concrete implementation. So, in the end I'm trying to provide a custom model. Something like: Java ------------------------ final Person p; Model crModel = new Model(){ getObject(){ return p.getDeptId(); } setObject(Object o){ // o is String! p.setDeptId( (String) o); } }; ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new ChoiceRenderer("id", "description")); cr.setModel(crModel); But i'm stucking into the same error, as this Model it's kind like a PropertyModel which would be assumed by having the former CompoundPropertyModel... Any thoughts ? Maybe rendering labels independently ? It's strange nobody has bumped into this situation before.. Maybe it's because i'm still thinking like I was using Struts... Thanks to both again, Cheers ! 2009/11/4 Pedro Santos <pedrosans@...> > Hi Sven, he stell can write some specialized render... but I think the best > way is you have your depid property of type Department. Than all this > thread > would not have started :) > > class YourCustomRender > { > @Override > public String getIdValue(Object object, int index) > { > if (object instanceof DTO) > { > return ((DTO)object).getDeptId() > } > else > { > return (String)object;//already is the depid string > } > } > > @Override > public Object getDisplayValue(Object object) > { > if (object instanceof DTO) > { > return ((DTO)object).getDescription(); > } > else > { > return contextData.getDTOBasedOnDepid(object); > } > } > } > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@...> wrote: > > > Hi, > > > > I have a question regarding the use of RadioChoice and ChoiceRenderer's > in > > conjunction with CompoundPropertyModel. I'm new to Wicket (but already a > > convinced user ;) ), so maybe my approach on this one is not at all as it > > should be... Any comments are welcome ! > > > > I'll get into details. Let's say I have a class in my domain model named > > Person. This entity has a property named 'deptId' of type String. The > > Person > > entity is the backing for a CompundPropertyModel applied to the whole > form. > > The 'deptId' field is inputted by the user, let's say, by means of a > > RadioChoice (I guess it makes no difference from a DropDownChoice taking > > into account the point of the question). The choice list for the > > RadioChoice > > component is a List made up of DTO objects with properties "id" and > > "description". To ensure proper rendering of labels, I use a suitable > > ChoiceRenderer. > > > > Now, problems come when the 'deptId' property has a value in the Person > > entity used in the CompoundPropertyModel. I get an error saying that > class > > String does not have any property called 'id' (I suppose this error comes > > from having a ModelObject of type String and also having a ChoiceRenderer > > refering to 'id' property). > > > > I'll provide some sample code: > > > > markup > > ------------- > > ... > > <form wicket:id="form"> > > ... > > <span valign="top" wicket:id="deptId"></span> > > ... > > </form> > > ... > > > > Java > > ------------- > > > > ... > > List<SimpleElementDTO> choices = contextData.getChoices(); > > Person p = new Person(...); > > Form f = new Form("form"){...}; > > f.setModel(new CompoundPropertyModel(p)); > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > > ChoiceRenderer("id", "description")); > > f.add(cr); > > ... > > > > > > I suppose the 'normal' way of doing things would be providing a custom > > Model > > to 'cr', but I'd like to know if there is a possibility to achieve this > > point still using CompoundPropertyModel... > > > > The stack trace I get is the following: > > > > WicketMessage: No get method defined for class: class java.lang.String > > expression: id > > Root cause: > > org.apache.wicket.WicketRuntimeException: No get method defined for > class: > > class java.lang.String expression: id > > at > > > > > org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) > > at > > > > > org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) > > at > > > > > org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) > > at > > > > > org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) > > at > > > > > org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) > > at > > > > > org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) > > at > > > > > org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) > > at org.apache.wicket.Component.renderComponent(Component.java:2480) > > at org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) > > at org.apache.wicket.Component.render(Component.java:2317) > > at > org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) > > ... > > > > > > -- > Pedro Henrique Oliveira dos Santos > -- "To err is human; to make real mess, you need a computer." |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersModel crModel = new Model(){
getObject(){ return contextData.getDTO(p.getDeptId()); } setObject(Object o){ p.setDeptId( ((DTO) o).getId()); } }; On Wed, Nov 4, 2009 at 2:32 PM, Xavier López <xavilope@...> wrote: > Hi Sven, Pedro, > > Thanks both for your quick reply. > > Ideally you would just set a Department instance into your Person objects > > > the best way is you have your depid property of type Department > > This was the first approach to take into account, but the idea was > discarded > in benefit of SimpleElementDTO, in order to provide only the necessary > information to Wicket Models, with the intention of not wasting any memory > on PageMaps due to Department object serializations... Also, this > SimpleElementDTO would be reusable throughout the whole application when > it's about Radio and DropDown Choices... > > write some specialized render > > > This kinda 'dirty-fix' idea was already crawling in my mind, trying to come > out someway. Thanks for providing a concrete implementation. > > So, in the end I'm trying to provide a custom model. Something like: > > Java > ------------------------ > final Person p; > > Model crModel = new Model(){ > getObject(){ > return p.getDeptId(); > } > setObject(Object o){ > // o is String! > p.setDeptId( (String) o); > } > }; > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > ChoiceRenderer("id", "description")); > cr.setModel(crModel); > > But i'm stucking into the same error, as this Model it's kind like a > PropertyModel which would be assumed by having the former > CompoundPropertyModel... > > Any thoughts ? Maybe rendering labels independently ? > > It's strange nobody has bumped into this situation before.. Maybe it's > because i'm still thinking like I was using Struts... > > Thanks to both again, > Cheers ! > > > 2009/11/4 Pedro Santos <pedrosans@...> > > > Hi Sven, he stell can write some specialized render... but I think the > best > > way is you have your depid property of type Department. Than all this > > thread > > would not have started :) > > > > class YourCustomRender > > { > > @Override > > public String getIdValue(Object object, int index) > > { > > if (object instanceof DTO) > > { > > return ((DTO)object).getDeptId() > > } > > else > > { > > return (String)object;//already is the depid string > > } > > } > > > > @Override > > public Object getDisplayValue(Object object) > > { > > if (object instanceof DTO) > > { > > return ((DTO)object).getDescription(); > > } > > else > > { > > return contextData.getDTOBasedOnDepid(object); > > } > > } > > } > > > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@...> wrote: > > > > > Hi, > > > > > > I have a question regarding the use of RadioChoice and ChoiceRenderer's > > in > > > conjunction with CompoundPropertyModel. I'm new to Wicket (but already > a > > > convinced user ;) ), so maybe my approach on this one is not at all as > it > > > should be... Any comments are welcome ! > > > > > > I'll get into details. Let's say I have a class in my domain model > named > > > Person. This entity has a property named 'deptId' of type String. The > > > Person > > > entity is the backing for a CompundPropertyModel applied to the whole > > form. > > > The 'deptId' field is inputted by the user, let's say, by means of a > > > RadioChoice (I guess it makes no difference from a DropDownChoice > taking > > > into account the point of the question). The choice list for the > > > RadioChoice > > > component is a List made up of DTO objects with properties "id" and > > > "description". To ensure proper rendering of labels, I use a suitable > > > ChoiceRenderer. > > > > > > Now, problems come when the 'deptId' property has a value in the Person > > > entity used in the CompoundPropertyModel. I get an error saying that > > class > > > String does not have any property called 'id' (I suppose this error > comes > > > from having a ModelObject of type String and also having a > ChoiceRenderer > > > refering to 'id' property). > > > > > > I'll provide some sample code: > > > > > > markup > > > ------------- > > > ... > > > <form wicket:id="form"> > > > ... > > > <span valign="top" wicket:id="deptId"></span> > > > ... > > > </form> > > > ... > > > > > > Java > > > ------------- > > > > > > ... > > > List<SimpleElementDTO> choices = contextData.getChoices(); > > > Person p = new Person(...); > > > Form f = new Form("form"){...}; > > > f.setModel(new CompoundPropertyModel(p)); > > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > > > ChoiceRenderer("id", "description")); > > > f.add(cr); > > > ... > > > > > > > > > I suppose the 'normal' way of doing things would be providing a custom > > > Model > > > to 'cr', but I'd like to know if there is a possibility to achieve this > > > point still using CompoundPropertyModel... > > > > > > The stack trace I get is the following: > > > > > > WicketMessage: No get method defined for class: class java.lang.String > > > expression: id > > > Root cause: > > > org.apache.wicket.WicketRuntimeException: No get method defined for > > class: > > > class java.lang.String expression: id > > > at > > > > > > > > > org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) > > > at > > > > > > > > > org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) > > > at > > > > > > > > > org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) > > > at > > > > > > > > > org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) > > > at > > > > > > > > > org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) > > > at > > > > > > > > > org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) > > > at > > > > > > > > > org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) > > > at org.apache.wicket.Component.renderComponent(Component.java:2480) > > > at > org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) > > > at org.apache.wicket.Component.render(Component.java:2317) > > > at > > org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) > > > ... > > > > > > > > > > > -- > > Pedro Henrique Oliveira dos Santos > > > > > > -- > "To err is human; to make real mess, you need a computer." > -- Pedro Henrique Oliveira dos Santos |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersWonderful !
Now I understand better. If only I could set the String deptId in an inner variable inside the Model and link it to the property with another model ! This comes from the fact that the building of the RadioChoice is made inside a Helper Class... Probably this is an atrocity, but I hope it'll transmit the idea... Helper.java ---------------------- public static RadioChoice getDeptRadioChoice(String id){ RadioChoice cr = new RadioChoice(id, getDeptsAsDTOList(), new SimpleElementChoiceRenderer()); Model crModel = new Model(){ String id; getObject(){ return getDptDTO(id); } setObject(Object o){ id = ( ((DTO) o).getId()); } }; cr.setModel(crModel); return cr; } PersonForm.java ----------------------------- RadioChoice cr = Helper.getDeptRadioChoice("deptId"); cr.setModel(new Model(cr.getModel()){ public Object getObject(){ return ((Model)super.getObject()).getObject(); } public void setObject(Object o){ ((Model)getObject()).setObject(o); p.setDeptId((String)m.getObject()); } }); Thanks ! 2009/11/4 Pedro Santos <pedrosans@...> > Model crModel = new Model(){ > getObject(){ > return contextData.getDTO(p.getDeptId()); > } > setObject(Object o){ > p.setDeptId( ((DTO) o).getId()); > } > }; > > On Wed, Nov 4, 2009 at 2:32 PM, Xavier López <xavilope@...> wrote: > > > Hi Sven, Pedro, > > > > Thanks both for your quick reply. > > > > Ideally you would just set a Department instance into your Person objects > > > > > > the best way is you have your depid property of type Department > > > > This was the first approach to take into account, but the idea was > > discarded > > in benefit of SimpleElementDTO, in order to provide only the necessary > > information to Wicket Models, with the intention of not wasting any > memory > > on PageMaps due to Department object serializations... Also, this > > SimpleElementDTO would be reusable throughout the whole application when > > it's about Radio and DropDown Choices... > > > > write some specialized render > > > > > This kinda 'dirty-fix' idea was already crawling in my mind, trying to > come > > out someway. Thanks for providing a concrete implementation. > > > > So, in the end I'm trying to provide a custom model. Something like: > > > > Java > > ------------------------ > > final Person p; > > > > Model crModel = new Model(){ > > getObject(){ > > return p.getDeptId(); > > } > > setObject(Object o){ > > // o is String! > > p.setDeptId( (String) o); > > } > > }; > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > > ChoiceRenderer("id", "description")); > > cr.setModel(crModel); > > > > But i'm stucking into the same error, as this Model it's kind like a > > PropertyModel which would be assumed by having the former > > CompoundPropertyModel... > > > > Any thoughts ? Maybe rendering labels independently ? > > > > It's strange nobody has bumped into this situation before.. Maybe it's > > because i'm still thinking like I was using Struts... > > > > Thanks to both again, > > Cheers ! > > > > > > 2009/11/4 Pedro Santos <pedrosans@...> > > > > > Hi Sven, he stell can write some specialized render... but I think the > > best > > > way is you have your depid property of type Department. Than all this > > > thread > > > would not have started :) > > > > > > class YourCustomRender > > > { > > > @Override > > > public String getIdValue(Object object, int index) > > > { > > > if (object instanceof DTO) > > > { > > > return ((DTO)object).getDeptId() > > > } > > > else > > > { > > > return (String)object;//already is the depid string > > > } > > > } > > > > > > @Override > > > public Object getDisplayValue(Object object) > > > { > > > if (object instanceof DTO) > > > { > > > return ((DTO)object).getDescription(); > > > } > > > else > > > { > > > return contextData.getDTOBasedOnDepid(object); > > > } > > > } > > > } > > > > > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@...> > wrote: > > > > > > > Hi, > > > > > > > > I have a question regarding the use of RadioChoice and > ChoiceRenderer's > > > in > > > > conjunction with CompoundPropertyModel. I'm new to Wicket (but > already > > a > > > > convinced user ;) ), so maybe my approach on this one is not at all > as > > it > > > > should be... Any comments are welcome ! > > > > > > > > I'll get into details. Let's say I have a class in my domain model > > named > > > > Person. This entity has a property named 'deptId' of type String. The > > > > Person > > > > entity is the backing for a CompundPropertyModel applied to the whole > > > form. > > > > The 'deptId' field is inputted by the user, let's say, by means of a > > > > RadioChoice (I guess it makes no difference from a DropDownChoice > > taking > > > > into account the point of the question). The choice list for the > > > > RadioChoice > > > > component is a List made up of DTO objects with properties "id" and > > > > "description". To ensure proper rendering of labels, I use a suitable > > > > ChoiceRenderer. > > > > > > > > Now, problems come when the 'deptId' property has a value in the > Person > > > > entity used in the CompoundPropertyModel. I get an error saying that > > > class > > > > String does not have any property called 'id' (I suppose this error > > comes > > > > from having a ModelObject of type String and also having a > > ChoiceRenderer > > > > refering to 'id' property). > > > > > > > > I'll provide some sample code: > > > > > > > > markup > > > > ------------- > > > > ... > > > > <form wicket:id="form"> > > > > ... > > > > <span valign="top" wicket:id="deptId"></span> > > > > ... > > > > </form> > > > > ... > > > > > > > > Java > > > > ------------- > > > > > > > > ... > > > > List<SimpleElementDTO> choices = contextData.getChoices(); > > > > Person p = new Person(...); > > > > Form f = new Form("form"){...}; > > > > f.setModel(new CompoundPropertyModel(p)); > > > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > > > > ChoiceRenderer("id", "description")); > > > > f.add(cr); > > > > ... > > > > > > > > > > > > I suppose the 'normal' way of doing things would be providing a > custom > > > > Model > > > > to 'cr', but I'd like to know if there is a possibility to achieve > this > > > > point still using CompoundPropertyModel... > > > > > > > > The stack trace I get is the following: > > > > > > > > WicketMessage: No get method defined for class: class > java.lang.String > > > > expression: id > > > > Root cause: > > > > org.apache.wicket.WicketRuntimeException: No get method defined for > > > class: > > > > class java.lang.String expression: id > > > > at > > > > > > > > > > > > > > org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) > > > > at > > > > > > > > > > > > > > org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) > > > > at > > > > > > > > > > > > > > org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) > > > > at > > > > > > > > > > > > > > org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) > > > > at > > > > > > > > > > > > > > org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) > > > > at > > > > > > > > > > > > > > org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) > > > > at > > > > > > > > > > > > > > org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) > > > > at org.apache.wicket.Component.renderComponent(Component.java:2480) > > > > at > > org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) > > > > at org.apache.wicket.Component.render(Component.java:2317) > > > > at > > > org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) > > > > ... > > > > > > > > > > > > > > > > -- > > > Pedro Henrique Oliveira dos Santos > > > > > > > > > > > -- > > "To err is human; to make real mess, you need a computer." > > > > > > -- > Pedro Henrique Oliveira dos Santos > -- "To err is human; to make real mess, you need a computer." |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersOk, I think that one has left you without words ;). I was only trying to
decouple in some way the 'conversion' of SimpleElementDTO to a String done by the Model, maybe pursuing some sort of 'Adapter' Model (chaining models are not meant for this are they?). After all, maybe I'll just stick to the ideal way of doing things, overriding detach() to get rid of superfluous properties, but I have to say in some cases this may be kind of artifical... For example, if I have two radiochoices representing a single boolean value (yes/no, with arbitrary labels), should I code a wrapper around Boolean with a description and a Boolean value in order to be able to cope with a suitable choiceRenderer ? Thanks for your time, Cheers ! 2009/11/4 Xavier López <xavilope@...> > Wonderful ! > > Now I understand better. If only I could set the String deptId in an inner > variable inside the Model and link it to the property with another model ! > This comes from the fact that the building of the RadioChoice is made > inside a Helper Class... > > Probably this is an atrocity, but I hope it'll transmit the idea... > > Helper.java > ---------------------- > public static RadioChoice getDeptRadioChoice(String id){ > RadioChoice cr = new RadioChoice(id, > getDeptsAsDTOList(), > new SimpleElementChoiceRenderer()); > > Model crModel = new Model(){ > String id; > getObject(){ > return getDptDTO(id); > } > setObject(Object o){ > id = ( ((DTO) o).getId()); > } > }; > cr.setModel(crModel); > return cr; > } > > PersonForm.java > ----------------------------- > > RadioChoice cr = Helper.getDeptRadioChoice("deptId"); > cr.setModel(new Model(cr.getModel()){ > public Object getObject(){ > return ((Model)super.getObject()).getObject(); > } > public void setObject(Object o){ > ((Model)getObject()).setObject(o); > p.setDeptId((String)m.getObject()); > } > }); > > Thanks ! > > > 2009/11/4 Pedro Santos <pedrosans@...> > >> Model crModel = new Model(){ >> getObject(){ >> return contextData.getDTO(p.getDeptId()); >> } >> setObject(Object o){ >> p.setDeptId( ((DTO) o).getId()); >> } >> }; >> >> On Wed, Nov 4, 2009 at 2:32 PM, Xavier López <xavilope@...> wrote: >> >> > Hi Sven, Pedro, >> > >> > Thanks both for your quick reply. >> > >> > Ideally you would just set a Department instance into your Person >> objects >> > >> > >> > the best way is you have your depid property of type Department >> > >> > This was the first approach to take into account, but the idea was >> > discarded >> > in benefit of SimpleElementDTO, in order to provide only the necessary >> > information to Wicket Models, with the intention of not wasting any >> memory >> > on PageMaps due to Department object serializations... Also, this >> > SimpleElementDTO would be reusable throughout the whole application when >> > it's about Radio and DropDown Choices... >> > >> > write some specialized render >> > > >> > This kinda 'dirty-fix' idea was already crawling in my mind, trying to >> come >> > out someway. Thanks for providing a concrete implementation. >> > >> > So, in the end I'm trying to provide a custom model. Something like: >> > >> > Java >> > ------------------------ >> > final Person p; >> > >> > Model crModel = new Model(){ >> > getObject(){ >> > return p.getDeptId(); >> > } >> > setObject(Object o){ >> > // o is String! >> > p.setDeptId( (String) o); >> > } >> > }; >> > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new >> > ChoiceRenderer("id", "description")); >> > cr.setModel(crModel); >> > >> > But i'm stucking into the same error, as this Model it's kind like a >> > PropertyModel which would be assumed by having the former >> > CompoundPropertyModel... >> > >> > Any thoughts ? Maybe rendering labels independently ? >> > >> > It's strange nobody has bumped into this situation before.. Maybe it's >> > because i'm still thinking like I was using Struts... >> > >> > Thanks to both again, >> > Cheers ! >> > >> > >> > 2009/11/4 Pedro Santos <pedrosans@...> >> > >> > > Hi Sven, he stell can write some specialized render... but I think the >> > best >> > > way is you have your depid property of type Department. Than all this >> > > thread >> > > would not have started :) >> > > >> > > class YourCustomRender >> > > { >> > > @Override >> > > public String getIdValue(Object object, int index) >> > > { >> > > if (object instanceof DTO) >> > > { >> > > return ((DTO)object).getDeptId() >> > > } >> > > else >> > > { >> > > return (String)object;//already is the depid string >> > > } >> > > } >> > > >> > > @Override >> > > public Object getDisplayValue(Object object) >> > > { >> > > if (object instanceof DTO) >> > > { >> > > return ((DTO)object).getDescription(); >> > > } >> > > else >> > > { >> > > return contextData.getDTOBasedOnDepid(object); >> > > } >> > > } >> > > } >> > > >> > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@...> >> wrote: >> > > >> > > > Hi, >> > > > >> > > > I have a question regarding the use of RadioChoice and >> ChoiceRenderer's >> > > in >> > > > conjunction with CompoundPropertyModel. I'm new to Wicket (but >> already >> > a >> > > > convinced user ;) ), so maybe my approach on this one is not at all >> as >> > it >> > > > should be... Any comments are welcome ! >> > > > >> > > > I'll get into details. Let's say I have a class in my domain model >> > named >> > > > Person. This entity has a property named 'deptId' of type String. >> The >> > > > Person >> > > > entity is the backing for a CompundPropertyModel applied to the >> whole >> > > form. >> > > > The 'deptId' field is inputted by the user, let's say, by means of a >> > > > RadioChoice (I guess it makes no difference from a DropDownChoice >> > taking >> > > > into account the point of the question). The choice list for the >> > > > RadioChoice >> > > > component is a List made up of DTO objects with properties "id" and >> > > > "description". To ensure proper rendering of labels, I use a >> suitable >> > > > ChoiceRenderer. >> > > > >> > > > Now, problems come when the 'deptId' property has a value in the >> Person >> > > > entity used in the CompoundPropertyModel. I get an error saying that >> > > class >> > > > String does not have any property called 'id' (I suppose this error >> > comes >> > > > from having a ModelObject of type String and also having a >> > ChoiceRenderer >> > > > refering to 'id' property). >> > > > >> > > > I'll provide some sample code: >> > > > >> > > > markup >> > > > ------------- >> > > > ... >> > > > <form wicket:id="form"> >> > > > ... >> > > > <span valign="top" wicket:id="deptId"></span> >> > > > ... >> > > > </form> >> > > > ... >> > > > >> > > > Java >> > > > ------------- >> > > > >> > > > ... >> > > > List<SimpleElementDTO> choices = contextData.getChoices(); >> > > > Person p = new Person(...); >> > > > Form f = new Form("form"){...}; >> > > > f.setModel(new CompoundPropertyModel(p)); >> > > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new >> > > > ChoiceRenderer("id", "description")); >> > > > f.add(cr); >> > > > ... >> > > > >> > > > >> > > > I suppose the 'normal' way of doing things would be providing a >> custom >> > > > Model >> > > > to 'cr', but I'd like to know if there is a possibility to achieve >> this >> > > > point still using CompoundPropertyModel... >> > > > >> > > > The stack trace I get is the following: >> > > > >> > > > WicketMessage: No get method defined for class: class >> java.lang.String >> > > > expression: id >> > > > Root cause: >> > > > org.apache.wicket.WicketRuntimeException: No get method defined for >> > > class: >> > > > class java.lang.String expression: id >> > > > at >> > > > >> > > > >> > > >> > >> org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) >> > > > at >> > > > >> > > > >> > > >> > >> org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) >> > > > at >> > > > >> > > > >> > > >> > >> org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) >> > > > at >> > > > >> > > > >> > > >> > >> org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) >> > > > at >> > > > >> > > > >> > > >> > >> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) >> > > > at >> > > > >> > > > >> > > >> > >> org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) >> > > > at >> > > > >> > > > >> > > >> > >> org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) >> > > > at org.apache.wicket.Component.renderComponent(Component.java:2480) >> > > > at >> > org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) >> > > > at org.apache.wicket.Component.render(Component.java:2317) >> > > > at >> > > >> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) >> > > > ... >> > > > >> > > >> > > >> > > >> > > -- >> > > Pedro Henrique Oliveira dos Santos >> > > >> > >> > >> > >> > -- >> > "To err is human; to make real mess, you need a computer." >> > >> >> >> >> -- >> Pedro Henrique Oliveira dos Santos >> > > > > -- > "To err is human; to make real mess, you need a computer." > -- "To err is human; to make real mess, you need a computer." |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersI'm not understanding you :-S
Ok, I think that one has left you without words ;). I was only trying to decouple in some way the 'conversion' of SimpleElementDTO to a String done by the Model, ok, here you already has an adapter class: DTO to component -> String to model object and vice versa maybe pursuing some sort of 'Adapter' Model (chaining models are not meant for this are they?). you need an adapter for an adapter? On Thu, Nov 5, 2009 at 6:18 AM, Xavier López <xavilope@...> wrote: > Ok, I think that one has left you without words ;). I was only trying to > decouple in some way the 'conversion' of SimpleElementDTO to a String done > by the Model, maybe pursuing some sort of 'Adapter' Model (chaining models > are not meant for this are they?). > After all, maybe I'll just stick to the ideal way of doing things, > overriding detach() to get rid of superfluous properties, but I have to say > in some cases this may be kind of artifical... > For example, if I have two radiochoices representing a single boolean value > (yes/no, with arbitrary labels), should I code a wrapper around Boolean > with > a description and a Boolean value in order to be able to cope with a > suitable choiceRenderer ? > > Thanks for your time, > Cheers ! > > 2009/11/4 Xavier López <xavilope@...> > > > Wonderful ! > > > > Now I understand better. If only I could set the String deptId in an > inner > > variable inside the Model and link it to the property with another model > ! > > This comes from the fact that the building of the RadioChoice is made > > inside a Helper Class... > > > > Probably this is an atrocity, but I hope it'll transmit the idea... > > > > Helper.java > > ---------------------- > > public static RadioChoice getDeptRadioChoice(String id){ > > RadioChoice cr = new RadioChoice(id, > > getDeptsAsDTOList(), > > new SimpleElementChoiceRenderer()); > > > > Model crModel = new Model(){ > > String id; > > getObject(){ > > return getDptDTO(id); > > } > > setObject(Object o){ > > id = ( ((DTO) o).getId()); > > } > > }; > > cr.setModel(crModel); > > return cr; > > } > > > > PersonForm.java > > ----------------------------- > > > > RadioChoice cr = Helper.getDeptRadioChoice("deptId"); > > cr.setModel(new Model(cr.getModel()){ > > public Object getObject(){ > > return ((Model)super.getObject()).getObject(); > > } > > public void setObject(Object o){ > > ((Model)getObject()).setObject(o); > > p.setDeptId((String)m.getObject()); > > } > > }); > > > > Thanks ! > > > > > > 2009/11/4 Pedro Santos <pedrosans@...> > > > >> Model crModel = new Model(){ > >> getObject(){ > >> return contextData.getDTO(p.getDeptId()); > >> } > >> setObject(Object o){ > >> p.setDeptId( ((DTO) o).getId()); > >> } > >> }; > >> > >> On Wed, Nov 4, 2009 at 2:32 PM, Xavier López <xavilope@...> > wrote: > >> > >> > Hi Sven, Pedro, > >> > > >> > Thanks both for your quick reply. > >> > > >> > Ideally you would just set a Department instance into your Person > >> objects > >> > > >> > > >> > the best way is you have your depid property of type Department > >> > > >> > This was the first approach to take into account, but the idea was > >> > discarded > >> > in benefit of SimpleElementDTO, in order to provide only the necessary > >> > information to Wicket Models, with the intention of not wasting any > >> memory > >> > on PageMaps due to Department object serializations... Also, this > >> > SimpleElementDTO would be reusable throughout the whole application > when > >> > it's about Radio and DropDown Choices... > >> > > >> > write some specialized render > >> > > > >> > This kinda 'dirty-fix' idea was already crawling in my mind, trying to > >> come > >> > out someway. Thanks for providing a concrete implementation. > >> > > >> > So, in the end I'm trying to provide a custom model. Something like: > >> > > >> > Java > >> > ------------------------ > >> > final Person p; > >> > > >> > Model crModel = new Model(){ > >> > getObject(){ > >> > return p.getDeptId(); > >> > } > >> > setObject(Object o){ > >> > // o is String! > >> > p.setDeptId( (String) o); > >> > } > >> > }; > >> > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > >> > ChoiceRenderer("id", "description")); > >> > cr.setModel(crModel); > >> > > >> > But i'm stucking into the same error, as this Model it's kind like a > >> > PropertyModel which would be assumed by having the former > >> > CompoundPropertyModel... > >> > > >> > Any thoughts ? Maybe rendering labels independently ? > >> > > >> > It's strange nobody has bumped into this situation before.. Maybe it's > >> > because i'm still thinking like I was using Struts... > >> > > >> > Thanks to both again, > >> > Cheers ! > >> > > >> > > >> > 2009/11/4 Pedro Santos <pedrosans@...> > >> > > >> > > Hi Sven, he stell can write some specialized render... but I think > the > >> > best > >> > > way is you have your depid property of type Department. Than all > this > >> > > thread > >> > > would not have started :) > >> > > > >> > > class YourCustomRender > >> > > { > >> > > @Override > >> > > public String getIdValue(Object object, int index) > >> > > { > >> > > if (object instanceof DTO) > >> > > { > >> > > return ((DTO)object).getDeptId() > >> > > } > >> > > else > >> > > { > >> > > return (String)object;//already is the depid string > >> > > } > >> > > } > >> > > > >> > > @Override > >> > > public Object getDisplayValue(Object object) > >> > > { > >> > > if (object instanceof DTO) > >> > > { > >> > > return ((DTO)object).getDescription(); > >> > > } > >> > > else > >> > > { > >> > > return contextData.getDTOBasedOnDepid(object); > >> > > } > >> > > } > >> > > } > >> > > > >> > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@...> > >> wrote: > >> > > > >> > > > Hi, > >> > > > > >> > > > I have a question regarding the use of RadioChoice and > >> ChoiceRenderer's > >> > > in > >> > > > conjunction with CompoundPropertyModel. I'm new to Wicket (but > >> already > >> > a > >> > > > convinced user ;) ), so maybe my approach on this one is not at > all > >> as > >> > it > >> > > > should be... Any comments are welcome ! > >> > > > > >> > > > I'll get into details. Let's say I have a class in my domain model > >> > named > >> > > > Person. This entity has a property named 'deptId' of type String. > >> The > >> > > > Person > >> > > > entity is the backing for a CompundPropertyModel applied to the > >> whole > >> > > form. > >> > > > The 'deptId' field is inputted by the user, let's say, by means of > a > >> > > > RadioChoice (I guess it makes no difference from a DropDownChoice > >> > taking > >> > > > into account the point of the question). The choice list for the > >> > > > RadioChoice > >> > > > component is a List made up of DTO objects with properties "id" > and > >> > > > "description". To ensure proper rendering of labels, I use a > >> suitable > >> > > > ChoiceRenderer. > >> > > > > >> > > > Now, problems come when the 'deptId' property has a value in the > >> Person > >> > > > entity used in the CompoundPropertyModel. I get an error saying > that > >> > > class > >> > > > String does not have any property called 'id' (I suppose this > error > >> > comes > >> > > > from having a ModelObject of type String and also having a > >> > ChoiceRenderer > >> > > > refering to 'id' property). > >> > > > > >> > > > I'll provide some sample code: > >> > > > > >> > > > markup > >> > > > ------------- > >> > > > ... > >> > > > <form wicket:id="form"> > >> > > > ... > >> > > > <span valign="top" wicket:id="deptId"></span> > >> > > > ... > >> > > > </form> > >> > > > ... > >> > > > > >> > > > Java > >> > > > ------------- > >> > > > > >> > > > ... > >> > > > List<SimpleElementDTO> choices = contextData.getChoices(); > >> > > > Person p = new Person(...); > >> > > > Form f = new Form("form"){...}; > >> > > > f.setModel(new CompoundPropertyModel(p)); > >> > > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > >> > > > ChoiceRenderer("id", "description")); > >> > > > f.add(cr); > >> > > > ... > >> > > > > >> > > > > >> > > > I suppose the 'normal' way of doing things would be providing a > >> custom > >> > > > Model > >> > > > to 'cr', but I'd like to know if there is a possibility to achieve > >> this > >> > > > point still using CompoundPropertyModel... > >> > > > > >> > > > The stack trace I get is the following: > >> > > > > >> > > > WicketMessage: No get method defined for class: class > >> java.lang.String > >> > > > expression: id > >> > > > Root cause: > >> > > > org.apache.wicket.WicketRuntimeException: No get method defined > for > >> > > class: > >> > > > class java.lang.String expression: id > >> > > > at > >> > > > > >> > > > > >> > > > >> > > >> > org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) > >> > > > at > >> > > > > >> > > > > >> > > > >> > > >> > org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) > >> > > > at > >> > > > > >> > > > > >> > > > >> > > >> > org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) > >> > > > at > >> > > > > >> > > > > >> > > > >> > > >> > org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) > >> > > > at > >> > > > > >> > > > > >> > > > >> > > >> > org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) > >> > > > at > >> > > > > >> > > > > >> > > > >> > > >> > org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) > >> > > > at > >> > > > > >> > > > > >> > > > >> > > >> > org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) > >> > > > at > org.apache.wicket.Component.renderComponent(Component.java:2480) > >> > > > at > >> > org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) > >> > > > at org.apache.wicket.Component.render(Component.java:2317) > >> > > > at > >> > > > >> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) > >> > > > ... > >> > > > > >> > > > >> > > > >> > > > >> > > -- > >> > > Pedro Henrique Oliveira dos Santos > >> > > > >> > > >> > > >> > > >> > -- > >> > "To err is human; to make real mess, you need a computer." > >> > > >> > >> > >> > >> -- > >> Pedro Henrique Oliveira dos Santos > >> > > > > > > > > -- > > "To err is human; to make real mess, you need a computer." > > > > > > -- > "To err is human; to make real mess, you need a computer." > -- Pedro Henrique Oliveira dos Santos |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersExcuse me for the messy explanations :)
To be honest, the problem I'm facing is not about deptId's, it's about 'sex' property (but eventually will get into something similar to deptId's some time). This property is modeled in the Person class with a String ("M" or "F"). What I'd like to do is to create this RadioChoice with proper id's and descriptions (localized with StringResourceModel) from a Helper class, in a way such that panels that use this class do not have to know anything about SimpleElemenDTO's... Just today I've found another post that may be of some help regarding this matter, it's about AbstractCheckBoxModel.. http://old.nabble.com/Checkbox-and-enum-value-td19655231.html Unfortunately, there is nothing like an AbstractRadioChoiceModel, but i don't think it's too hard to customize my own from AbstractCheckBoxModel... Also, I've noticed AbstractChoice on 1.4.0 API's but, alas, I'm on 1.3.5 Hope I've explained myself better ;) Thanks for your time and interest, Cheers ! 2009/11/5 Pedro Santos <pedrosans@...> > I'm not understanding you :-S > > Ok, I think that one has left you without words ;). I was only trying to > decouple in some way the 'conversion' of SimpleElementDTO to a String done > by the Model, > ok, here you already has an adapter class: DTO to component -> String to > model object and vice versa > > maybe pursuing some sort of 'Adapter' Model (chaining models > are not meant for this are they?). > you need an adapter for an adapter? > > On Thu, Nov 5, 2009 at 6:18 AM, Xavier López <xavilope@...> wrote: > > > Ok, I think that one has left you without words ;). I was only trying to > > decouple in some way the 'conversion' of SimpleElementDTO to a String > done > > by the Model, maybe pursuing some sort of 'Adapter' Model (chaining > models > > are not meant for this are they?). > > After all, maybe I'll just stick to the ideal way of doing things, > > overriding detach() to get rid of superfluous properties, but I have to > say > > in some cases this may be kind of artifical... > > For example, if I have two radiochoices representing a single boolean > value > > (yes/no, with arbitrary labels), should I code a wrapper around Boolean > > with > > a description and a Boolean value in order to be able to cope with a > > suitable choiceRenderer ? > > > > Thanks for your time, > > Cheers ! > > > > 2009/11/4 Xavier López <xavilope@...> > > > > > Wonderful ! > > > > > > Now I understand better. If only I could set the String deptId in an > > inner > > > variable inside the Model and link it to the property with another > model > > ! > > > This comes from the fact that the building of the RadioChoice is made > > > inside a Helper Class... > > > > > > Probably this is an atrocity, but I hope it'll transmit the idea... > > > > > > Helper.java > > > ---------------------- > > > public static RadioChoice getDeptRadioChoice(String id){ > > > RadioChoice cr = new RadioChoice(id, > > > getDeptsAsDTOList(), > > > new SimpleElementChoiceRenderer()); > > > > > > Model crModel = new Model(){ > > > String id; > > > getObject(){ > > > return getDptDTO(id); > > > } > > > setObject(Object o){ > > > id = ( ((DTO) o).getId()); > > > } > > > }; > > > cr.setModel(crModel); > > > return cr; > > > } > > > > > > PersonForm.java > > > ----------------------------- > > > > > > RadioChoice cr = Helper.getDeptRadioChoice("deptId"); > > > cr.setModel(new Model(cr.getModel()){ > > > public Object getObject(){ > > > return ((Model)super.getObject()).getObject(); > > > } > > > public void setObject(Object o){ > > > ((Model)getObject()).setObject(o); > > > p.setDeptId((String)m.getObject()); > > > } > > > }); > > > > > > Thanks ! > > > > > > > > > 2009/11/4 Pedro Santos <pedrosans@...> > > > > > >> Model crModel = new Model(){ > > >> getObject(){ > > >> return contextData.getDTO(p.getDeptId()); > > >> } > > >> setObject(Object o){ > > >> p.setDeptId( ((DTO) o).getId()); > > >> } > > >> }; > > >> > > >> On Wed, Nov 4, 2009 at 2:32 PM, Xavier López <xavilope@...> > > wrote: > > >> > > >> > Hi Sven, Pedro, > > >> > > > >> > Thanks both for your quick reply. > > >> > > > >> > Ideally you would just set a Department instance into your Person > > >> objects > > >> > > > >> > > > >> > the best way is you have your depid property of type Department > > >> > > > >> > This was the first approach to take into account, but the idea was > > >> > discarded > > >> > in benefit of SimpleElementDTO, in order to provide only the > necessary > > >> > information to Wicket Models, with the intention of not wasting any > > >> memory > > >> > on PageMaps due to Department object serializations... Also, this > > >> > SimpleElementDTO would be reusable throughout the whole application > > when > > >> > it's about Radio and DropDown Choices... > > >> > > > >> > write some specialized render > > >> > > > > >> > This kinda 'dirty-fix' idea was already crawling in my mind, trying > to > > >> come > > >> > out someway. Thanks for providing a concrete implementation. > > >> > > > >> > So, in the end I'm trying to provide a custom model. Something like: > > >> > > > >> > Java > > >> > ------------------------ > > >> > final Person p; > > >> > > > >> > Model crModel = new Model(){ > > >> > getObject(){ > > >> > return p.getDeptId(); > > >> > } > > >> > setObject(Object o){ > > >> > // o is String! > > >> > p.setDeptId( (String) o); > > >> > } > > >> > }; > > >> > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > > >> > ChoiceRenderer("id", "description")); > > >> > cr.setModel(crModel); > > >> > > > >> > But i'm stucking into the same error, as this Model it's kind like a > > >> > PropertyModel which would be assumed by having the former > > >> > CompoundPropertyModel... > > >> > > > >> > Any thoughts ? Maybe rendering labels independently ? > > >> > > > >> > It's strange nobody has bumped into this situation before.. Maybe > it's > > >> > because i'm still thinking like I was using Struts... > > >> > > > >> > Thanks to both again, > > >> > Cheers ! > > >> > > > >> > > > >> > 2009/11/4 Pedro Santos <pedrosans@...> > > >> > > > >> > > Hi Sven, he stell can write some specialized render... but I think > > the > > >> > best > > >> > > way is you have your depid property of type Department. Than all > > this > > >> > > thread > > >> > > would not have started :) > > >> > > > > >> > > class YourCustomRender > > >> > > { > > >> > > @Override > > >> > > public String getIdValue(Object object, int index) > > >> > > { > > >> > > if (object instanceof DTO) > > >> > > { > > >> > > return ((DTO)object).getDeptId() > > >> > > } > > >> > > else > > >> > > { > > >> > > return (String)object;//already is the depid string > > >> > > } > > >> > > } > > >> > > > > >> > > @Override > > >> > > public Object getDisplayValue(Object object) > > >> > > { > > >> > > if (object instanceof DTO) > > >> > > { > > >> > > return ((DTO)object).getDescription(); > > >> > > } > > >> > > else > > >> > > { > > >> > > return contextData.getDTOBasedOnDepid(object); > > >> > > } > > >> > > } > > >> > > } > > >> > > > > >> > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@...> > > >> wrote: > > >> > > > > >> > > > Hi, > > >> > > > > > >> > > > I have a question regarding the use of RadioChoice and > > >> ChoiceRenderer's > > >> > > in > > >> > > > conjunction with CompoundPropertyModel. I'm new to Wicket (but > > >> already > > >> > a > > >> > > > convinced user ;) ), so maybe my approach on this one is not at > > all > > >> as > > >> > it > > >> > > > should be... Any comments are welcome ! > > >> > > > > > >> > > > I'll get into details. Let's say I have a class in my domain > model > > >> > named > > >> > > > Person. This entity has a property named 'deptId' of type > String. > > >> The > > >> > > > Person > > >> > > > entity is the backing for a CompundPropertyModel applied to the > > >> whole > > >> > > form. > > >> > > > The 'deptId' field is inputted by the user, let's say, by means > of > > a > > >> > > > RadioChoice (I guess it makes no difference from a > DropDownChoice > > >> > taking > > >> > > > into account the point of the question). The choice list for the > > >> > > > RadioChoice > > >> > > > component is a List made up of DTO objects with properties "id" > > and > > >> > > > "description". To ensure proper rendering of labels, I use a > > >> suitable > > >> > > > ChoiceRenderer. > > >> > > > > > >> > > > Now, problems come when the 'deptId' property has a value in the > > >> Person > > >> > > > entity used in the CompoundPropertyModel. I get an error saying > > that > > >> > > class > > >> > > > String does not have any property called 'id' (I suppose this > > error > > >> > comes > > >> > > > from having a ModelObject of type String and also having a > > >> > ChoiceRenderer > > >> > > > refering to 'id' property). > > >> > > > > > >> > > > I'll provide some sample code: > > >> > > > > > >> > > > markup > > >> > > > ------------- > > >> > > > ... > > >> > > > <form wicket:id="form"> > > >> > > > ... > > >> > > > <span valign="top" wicket:id="deptId"></span> > > >> > > > ... > > >> > > > </form> > > >> > > > ... > > >> > > > > > >> > > > Java > > >> > > > ------------- > > >> > > > > > >> > > > ... > > >> > > > List<SimpleElementDTO> choices = contextData.getChoices(); > > >> > > > Person p = new Person(...); > > >> > > > Form f = new Form("form"){...}; > > >> > > > f.setModel(new CompoundPropertyModel(p)); > > >> > > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new > > >> > > > ChoiceRenderer("id", "description")); > > >> > > > f.add(cr); > > >> > > > ... > > >> > > > > > >> > > > > > >> > > > I suppose the 'normal' way of doing things would be providing a > > >> custom > > >> > > > Model > > >> > > > to 'cr', but I'd like to know if there is a possibility to > achieve > > >> this > > >> > > > point still using CompoundPropertyModel... > > >> > > > > > >> > > > The stack trace I get is the following: > > >> > > > > > >> > > > WicketMessage: No get method defined for class: class > > >> java.lang.String > > >> > > > expression: id > > >> > > > Root cause: > > >> > > > org.apache.wicket.WicketRuntimeException: No get method defined > > for > > >> > > class: > > >> > > > class java.lang.String expression: id > > >> > > > at > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) > > >> > > > at > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) > > >> > > > at > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) > > >> > > > at > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) > > >> > > > at > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) > > >> > > > at > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) > > >> > > > at > > >> > > > > > >> > > > > > >> > > > > >> > > > >> > > > org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) > > >> > > > at > > org.apache.wicket.Component.renderComponent(Component.java:2480) > > >> > > > at > > >> > > org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) > > >> > > > at org.apache.wicket.Component.render(Component.java:2317) > > >> > > > at > > >> > > > > >> > org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) > > >> > > > ... > > >> > > > > > >> > > > > >> > > > > >> > > > > >> > > -- > > >> > > Pedro Henrique Oliveira dos Santos > > >> > > > > >> > > > >> > > > >> > > > >> > -- > > >> > "To err is human; to make real mess, you need a computer." > > >> > > > >> > > >> > > >> > > >> -- > > >> Pedro Henrique Oliveira dos Santos > > >> > > > > > > > > > > > > -- > > > "To err is human; to make real mess, you need a computer." > > > > > > > > > > > -- > > "To err is human; to make real mess, you need a computer." > > > > > > -- > Pedro Henrique Oliveira dos Santos > -- "To err is human; to make real mess, you need a computer." |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersFinally I've managed to cope the CompoundPropertyModel along with a
RadioGroup and Radio's instead of RadioChoice. This is the example: Markup: <span wicket:id="sex"> <span wicket:id="radioList"> <input type="radio" wicket:id="radio"/> <label wicket:id="label"><span wicket:id="labText"/></label> </span> </span> Java: public class SimpleElementRadioGroup extends RadioGroup { /** Constructor without Model in order to use CompoundPropertyModel <br/> * choices.getModelObject() must return a List<SimpleElementDTO> */ public SimpleElementRadioGroup(String id, IModel choices) { super(id); ListView l = new ListView("radioList", choices) { private static final long serialVersionUID = 1L; protected void populateItem(ListItem item) { final SimpleElementDTO element = (SimpleElementDTO) item.getModelObject(); Radio r = new Radio("radio", new Model(element.getId())); item.add(r); FormComponentLabel l = new FormComponentLabel("label", r); item.add(r); Label labelText = new Label("labText", new AbstractReadOnlyModel(){ @Override public Object getObject() { return element.getDescription(); } }); labelText.setRenderBodyOnly(true); l.add(labelText); item.add(l); item.setRenderBodyOnly(true); } }; add(l); } Panel: (with compoundPropertyModel backed by entity with String 'sex' field) ... RadioGroup rg = new SimpleElementRadioGroup("sex", new AbstractReadOnlyModel(){ public void getObject() { return contextData.getDTOList(...); } }); add(rg); ... Now, I''ve been seeking a way to extract the 'radioList' tag and its children from the panel's markup in order to provide reusability. I've seen it's impossible to associate a markup file to a Component, so I'm trying to do it by manipulating tag body, like RadioChoice does, implementing 'onComponentTagBody' on SimpleElementRadioGroup. Like this: @Override protected final void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { /* <span wicket:id="radioList"> <input type="radio" wicket:id="radio"/> <label wicket:id="label"><span wicket:id="labText"/></label> </span> */ // Buffer to hold generated body final AppendingStringBuffer buffer = new AppendingStringBuffer(); buffer.append("<span wicket:id=\"radioList\">"); buffer.append("<input type=\"radio\" wicket:id=\"radio\"/>"); buffer.append("<label wicket:id=\"label\"><span wicket:id=\"labText\"/></label>"); buffer.append("</span>"); // Replace body replaceComponentTagBody(markupStream, openTag, buffer); } Nonetheless, I keep getting an exception indicating that all tags that should have been placed in the component's body have not been added in the markup... I've also tried to invoke super.onComponentTagBody(markupStream,openTag) at the end of my overriding implementation, but I get the same result. I'd greatly appreciate any help or directions with this problem. 2009/11/5 Xavier López <xavilope@...> > Excuse me for the messy explanations :) > > To be honest, the problem I'm facing is not about deptId's, it's about > 'sex' property (but eventually will get into something similar to deptId's > some time). > This property is modeled in the Person class with a String ("M" or "F"). > What I'd like to do is to create this RadioChoice with proper id's and > descriptions (localized with StringResourceModel) from a Helper class, in a > way such that panels that use this class do not have to know anything about > SimpleElemenDTO's... > > Just today I've found another post that may be of some help regarding this > matter, it's about AbstractCheckBoxModel.. > http://old.nabble.com/Checkbox-and-enum-value-td19655231.html > > Unfortunately, there is nothing like an AbstractRadioChoiceModel, but i > don't think it's too hard to customize my own from AbstractCheckBoxModel... > > Also, I've noticed AbstractChoice on 1.4.0 API's but, alas, I'm on 1.3.5 > > Hope I've explained myself better ;) > > Thanks for your time and interest, > Cheers ! > > 2009/11/5 Pedro Santos <pedrosans@...> > > I'm not understanding you :-S >> >> Ok, I think that one has left you without words ;). I was only trying to >> decouple in some way the 'conversion' of SimpleElementDTO to a String done >> by the Model, >> ok, here you already has an adapter class: DTO to component -> String to >> model object and vice versa >> >> maybe pursuing some sort of 'Adapter' Model (chaining models >> are not meant for this are they?). >> you need an adapter for an adapter? >> >> On Thu, Nov 5, 2009 at 6:18 AM, Xavier López <xavilope@...> wrote: >> >> > Ok, I think that one has left you without words ;). I was only trying to >> > decouple in some way the 'conversion' of SimpleElementDTO to a String >> done >> > by the Model, maybe pursuing some sort of 'Adapter' Model (chaining >> models >> > are not meant for this are they?). >> > After all, maybe I'll just stick to the ideal way of doing things, >> > overriding detach() to get rid of superfluous properties, but I have to >> say >> > in some cases this may be kind of artifical... >> > For example, if I have two radiochoices representing a single boolean >> value >> > (yes/no, with arbitrary labels), should I code a wrapper around Boolean >> > with >> > a description and a Boolean value in order to be able to cope with a >> > suitable choiceRenderer ? >> > >> > Thanks for your time, >> > Cheers ! >> > >> > 2009/11/4 Xavier López <xavilope@...> >> > >> > > Wonderful ! >> > > >> > > Now I understand better. If only I could set the String deptId in an >> > inner >> > > variable inside the Model and link it to the property with another >> model >> > ! >> > > This comes from the fact that the building of the RadioChoice is made >> > > inside a Helper Class... >> > > >> > > Probably this is an atrocity, but I hope it'll transmit the idea... >> > > >> > > Helper.java >> > > ---------------------- >> > > public static RadioChoice getDeptRadioChoice(String id){ >> > > RadioChoice cr = new RadioChoice(id, >> > > getDeptsAsDTOList(), >> > > new SimpleElementChoiceRenderer()); >> > > >> > > Model crModel = new Model(){ >> > > String id; >> > > getObject(){ >> > > return getDptDTO(id); >> > > } >> > > setObject(Object o){ >> > > id = ( ((DTO) o).getId()); >> > > } >> > > }; >> > > cr.setModel(crModel); >> > > return cr; >> > > } >> > > >> > > PersonForm.java >> > > ----------------------------- >> > > >> > > RadioChoice cr = Helper.getDeptRadioChoice("deptId"); >> > > cr.setModel(new Model(cr.getModel()){ >> > > public Object getObject(){ >> > > return ((Model)super.getObject()).getObject(); >> > > } >> > > public void setObject(Object o){ >> > > ((Model)getObject()).setObject(o); >> > > p.setDeptId((String)m.getObject()); >> > > } >> > > }); >> > > >> > > Thanks ! >> > > >> > > >> > > 2009/11/4 Pedro Santos <pedrosans@...> >> > > >> > >> Model crModel = new Model(){ >> > >> getObject(){ >> > >> return contextData.getDTO(p.getDeptId()); >> > >> } >> > >> setObject(Object o){ >> > >> p.setDeptId( ((DTO) o).getId()); >> > >> } >> > >> }; >> > >> >> > >> On Wed, Nov 4, 2009 at 2:32 PM, Xavier López <xavilope@...> >> > wrote: >> > >> >> > >> > Hi Sven, Pedro, >> > >> > >> > >> > Thanks both for your quick reply. >> > >> > >> > >> > Ideally you would just set a Department instance into your Person >> > >> objects >> > >> > >> > >> > >> > >> > the best way is you have your depid property of type Department >> > >> > >> > >> > This was the first approach to take into account, but the idea was >> > >> > discarded >> > >> > in benefit of SimpleElementDTO, in order to provide only the >> necessary >> > >> > information to Wicket Models, with the intention of not wasting any >> > >> memory >> > >> > on PageMaps due to Department object serializations... Also, this >> > >> > SimpleElementDTO would be reusable throughout the whole application >> > when >> > >> > it's about Radio and DropDown Choices... >> > >> > >> > >> > write some specialized render >> > >> > > >> > >> > This kinda 'dirty-fix' idea was already crawling in my mind, trying >> to >> > >> come >> > >> > out someway. Thanks for providing a concrete implementation. >> > >> > >> > >> > So, in the end I'm trying to provide a custom model. Something >> like: >> > >> > >> > >> > Java >> > >> > ------------------------ >> > >> > final Person p; >> > >> > >> > >> > Model crModel = new Model(){ >> > >> > getObject(){ >> > >> > return p.getDeptId(); >> > >> > } >> > >> > setObject(Object o){ >> > >> > // o is String! >> > >> > p.setDeptId( (String) o); >> > >> > } >> > >> > }; >> > >> > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new >> > >> > ChoiceRenderer("id", "description")); >> > >> > cr.setModel(crModel); >> > >> > >> > >> > But i'm stucking into the same error, as this Model it's kind like >> a >> > >> > PropertyModel which would be assumed by having the former >> > >> > CompoundPropertyModel... >> > >> > >> > >> > Any thoughts ? Maybe rendering labels independently ? >> > >> > >> > >> > It's strange nobody has bumped into this situation before.. Maybe >> it's >> > >> > because i'm still thinking like I was using Struts... >> > >> > >> > >> > Thanks to both again, >> > >> > Cheers ! >> > >> > >> > >> > >> > >> > 2009/11/4 Pedro Santos <pedrosans@...> >> > >> > >> > >> > > Hi Sven, he stell can write some specialized render... but I >> think >> > the >> > >> > best >> > >> > > way is you have your depid property of type Department. Than all >> > this >> > >> > > thread >> > >> > > would not have started :) >> > >> > > >> > >> > > class YourCustomRender >> > >> > > { >> > >> > > @Override >> > >> > > public String getIdValue(Object object, int index) >> > >> > > { >> > >> > > if (object instanceof DTO) >> > >> > > { >> > >> > > return ((DTO)object).getDeptId() >> > >> > > } >> > >> > > else >> > >> > > { >> > >> > > return (String)object;//already is the depid >> string >> > >> > > } >> > >> > > } >> > >> > > >> > >> > > @Override >> > >> > > public Object getDisplayValue(Object object) >> > >> > > { >> > >> > > if (object instanceof DTO) >> > >> > > { >> > >> > > return ((DTO)object).getDescription(); >> > >> > > } >> > >> > > else >> > >> > > { >> > >> > > return contextData.getDTOBasedOnDepid(object); >> > >> > > } >> > >> > > } >> > >> > > } >> > >> > > >> > >> > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López <xavilope@... >> > >> > >> wrote: >> > >> > > >> > >> > > > Hi, >> > >> > > > >> > >> > > > I have a question regarding the use of RadioChoice and >> > >> ChoiceRenderer's >> > >> > > in >> > >> > > > conjunction with CompoundPropertyModel. I'm new to Wicket (but >> > >> already >> > >> > a >> > >> > > > convinced user ;) ), so maybe my approach on this one is not at >> > all >> > >> as >> > >> > it >> > >> > > > should be... Any comments are welcome ! >> > >> > > > >> > >> > > > I'll get into details. Let's say I have a class in my domain >> model >> > >> > named >> > >> > > > Person. This entity has a property named 'deptId' of type >> String. >> > >> The >> > >> > > > Person >> > >> > > > entity is the backing for a CompundPropertyModel applied to the >> > >> whole >> > >> > > form. >> > >> > > > The 'deptId' field is inputted by the user, let's say, by means >> of >> > a >> > >> > > > RadioChoice (I guess it makes no difference from a >> DropDownChoice >> > >> > taking >> > >> > > > into account the point of the question). The choice list for >> the >> > >> > > > RadioChoice >> > >> > > > component is a List made up of DTO objects with properties "id" >> > and >> > >> > > > "description". To ensure proper rendering of labels, I use a >> > >> suitable >> > >> > > > ChoiceRenderer. >> > >> > > > >> > >> > > > Now, problems come when the 'deptId' property has a value in >> the >> > >> Person >> > >> > > > entity used in the CompoundPropertyModel. I get an error saying >> > that >> > >> > > class >> > >> > > > String does not have any property called 'id' (I suppose this >> > error >> > >> > comes >> > >> > > > from having a ModelObject of type String and also having a >> > >> > ChoiceRenderer >> > >> > > > refering to 'id' property). >> > >> > > > >> > >> > > > I'll provide some sample code: >> > >> > > > >> > >> > > > markup >> > >> > > > ------------- >> > >> > > > ... >> > >> > > > <form wicket:id="form"> >> > >> > > > ... >> > >> > > > <span valign="top" wicket:id="deptId"></span> >> > >> > > > ... >> > >> > > > </form> >> > >> > > > ... >> > >> > > > >> > >> > > > Java >> > >> > > > ------------- >> > >> > > > >> > >> > > > ... >> > >> > > > List<SimpleElementDTO> choices = contextData.getChoices(); >> > >> > > > Person p = new Person(...); >> > >> > > > Form f = new Form("form"){...}; >> > >> > > > f.setModel(new CompoundPropertyModel(p)); >> > >> > > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new >> > >> > > > ChoiceRenderer("id", "description")); >> > >> > > > f.add(cr); >> > >> > > > ... >> > >> > > > >> > >> > > > >> > >> > > > I suppose the 'normal' way of doing things would be providing a >> > >> custom >> > >> > > > Model >> > >> > > > to 'cr', but I'd like to know if there is a possibility to >> achieve >> > >> this >> > >> > > > point still using CompoundPropertyModel... >> > >> > > > >> > >> > > > The stack trace I get is the following: >> > >> > > > >> > >> > > > WicketMessage: No get method defined for class: class >> > >> java.lang.String >> > >> > > > expression: id >> > >> > > > Root cause: >> > >> > > > org.apache.wicket.WicketRuntimeException: No get method defined >> > for >> > >> > > class: >> > >> > > > class java.lang.String expression: id >> > >> > > > at >> > >> > > > >> > >> > > > >> > >> > > >> > >> > >> > >> >> > >> org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) >> > >> > > > at >> > >> > > > >> > >> > > > >> > >> > > >> > >> > >> > >> >> > >> org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) >> > >> > > > at >> > >> > > > >> > >> > > > >> > >> > > >> > >> > >> > >> >> > >> org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) >> > >> > > > at >> > >> > > > >> > >> > > > >> > >> > > >> > >> > >> > >> >> > >> org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) >> > >> > > > at >> > >> > > > >> > >> > > > >> > >> > > >> > >> > >> > >> >> > >> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) >> > >> > > > at >> > >> > > > >> > >> > > > >> > >> > > >> > >> > >> > >> >> > >> org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) >> > >> > > > at >> > >> > > > >> > >> > > > >> > >> > > >> > >> > >> > >> >> > >> org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) >> > >> > > > at >> > org.apache.wicket.Component.renderComponent(Component.java:2480) >> > >> > > > at >> > >> > >> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) >> > >> > > > at org.apache.wicket.Component.render(Component.java:2317) >> > >> > > > at >> > >> > > >> > >> >> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) >> > >> > > > ... >> > >> > > > >> > >> > > >> > >> > > >> > >> > > >> > >> > > -- >> > >> > > Pedro Henrique Oliveira dos Santos >> > >> > > >> > >> > >> > >> > >> > >> > >> > >> > -- >> > >> > "To err is human; to make real mess, you need a computer." >> > >> > >> > >> >> > >> >> > >> >> > >> -- >> > >> Pedro Henrique Oliveira dos Santos >> > >> >> > > >> > > >> > > >> > > -- >> > > "To err is human; to make real mess, you need a computer." >> > > >> > >> > >> > >> > -- >> > "To err is human; to make real mess, you need a computer." >> > >> >> >> >> -- >> Pedro Henrique Oliveira dos Santos >> > > > > -- > "To err is human; to make real mess, you need a computer." > -- "To err is human; to make real mess, you need a computer." |
|
|
Re: CompoundPropertyModel in conjunction with RadioChoice&ChoiceRenderersHi,
I've realized that overriding onComponentTagBody like this is not working, because it's like this method is expected to produce only plain html (no wicket:id tags)... I suppose the reason to try to make it final was to avoid this messy behaviors :) Anyway, definitely I'm not building all html <input> and <label> tags from the list of choices in onComponentTagBody. If only I could get this markup: <span wicket:id="radioList"> <input type="radio" wicket:id="radio"/> <label wicket:id="label"><span wicket:id="labText"/></label> </span> somehow inside the SimpleElementRadioGroup... I only can think of nesting a Panel in it, which will have that markup, but panels that use SimpleElementRadioGroup still have to put an extra <span> tag for that panel... <span wicket:id="genderChoice"> <span wicket:id="genderChoiceRadios"/> </span> Well, this may be good for me (considering my former crazy alternatives) , but now I am only curious about if it's possible to move someway out the 'genderChoiceRadios' element from people who will be using this component... Thanks ! 2009/11/5 Xavier López <xavilope@...> > Finally I've managed to cope the CompoundPropertyModel along with a > RadioGroup and Radio's instead of RadioChoice. > > This is the example: > > Markup: > <span wicket:id="sex"> > <span wicket:id="radioList"> > <input type="radio" wicket:id="radio"/> > <label wicket:id="label"><span wicket:id="labText"/></label> > </span> > </span> > > Java: > public class SimpleElementRadioGroup extends RadioGroup { > /** Constructor without Model in order to use CompoundPropertyModel > <br/> > * choices.getModelObject() must return a List<SimpleElementDTO> > */ > public SimpleElementRadioGroup(String id, IModel choices) { > super(id); > ListView l = new ListView("radioList", choices) { > private static final long serialVersionUID = 1L; > protected void populateItem(ListItem item) > { > final SimpleElementDTO element = (SimpleElementDTO) > item.getModelObject(); > Radio r = new Radio("radio", new Model(element.getId())); > item.add(r); > FormComponentLabel l = new FormComponentLabel("label", r); > item.add(r); > Label labelText = new Label("labText", new > AbstractReadOnlyModel(){ > @Override > public Object getObject() { return > element.getDescription(); } > }); > labelText.setRenderBodyOnly(true); > l.add(labelText); > item.add(l); > item.setRenderBodyOnly(true); > } > }; > add(l); > } > > Panel: (with compoundPropertyModel backed by entity with String 'sex' > field) > ... > RadioGroup rg = new SimpleElementRadioGroup("sex", new > AbstractReadOnlyModel(){ > public void getObject() { return contextData.getDTOList(...); } > }); > add(rg); > ... > > Now, I''ve been seeking a way to extract the 'radioList' tag and its > children from the panel's markup in order to provide reusability. I've seen > it's impossible to associate a markup file to a Component, so I'm trying to > do it by manipulating tag body, like RadioChoice does, implementing > 'onComponentTagBody' on SimpleElementRadioGroup. Like this: > > @Override > protected final void onComponentTagBody(final MarkupStream > markupStream, final ComponentTag openTag) > { > > /* > <span wicket:id="radioList"> > > <input type="radio" wicket:id="radio"/> > <label wicket:id="label"><span wicket:id="labText"/></label> > </span> > */ > > // Buffer to hold generated body > final AppendingStringBuffer buffer = new > AppendingStringBuffer(); > > buffer.append("<span wicket:id=\"radioList\">"); > buffer.append("<input type=\"radio\" wicket:id=\"radio\"/>"); > buffer.append("<label wicket:id=\"label\"><span > wicket:id=\"labText\"/></label>"); > buffer.append("</span>"); > > // Replace body > replaceComponentTagBody(markupStream, openTag, buffer); > } > > Nonetheless, I keep getting an exception indicating that all tags that > should have been placed in the component's body have not been added in the > markup... I've also tried to invoke > super.onComponentTagBody(markupStream,openTag) at the end of my overriding > implementation, but I get the same result. > > I'd greatly appreciate any help or directions with this problem. > > 2009/11/5 Xavier López <xavilope@...> > > Excuse me for the messy explanations :) >> >> To be honest, the problem I'm facing is not about deptId's, it's about >> 'sex' property (but eventually will get into something similar to deptId's >> some time). >> This property is modeled in the Person class with a String ("M" or "F"). >> What I'd like to do is to create this RadioChoice with proper id's and >> descriptions (localized with StringResourceModel) from a Helper class, in a >> way such that panels that use this class do not have to know anything about >> SimpleElemenDTO's... >> >> Just today I've found another post that may be of some help regarding this >> matter, it's about AbstractCheckBoxModel.. >> http://old.nabble.com/Checkbox-and-enum-value-td19655231.html >> >> Unfortunately, there is nothing like an AbstractRadioChoiceModel, but i >> don't think it's too hard to customize my own from AbstractCheckBoxModel... >> >> Also, I've noticed AbstractChoice on 1.4.0 API's but, alas, I'm on 1.3.5 >> >> Hope I've explained myself better ;) >> >> Thanks for your time and interest, >> Cheers ! >> >> 2009/11/5 Pedro Santos <pedrosans@...> >> >> I'm not understanding you :-S >>> >>> Ok, I think that one has left you without words ;). I was only trying to >>> decouple in some way the 'conversion' of SimpleElementDTO to a String >>> done >>> by the Model, >>> ok, here you already has an adapter class: DTO to component -> String to >>> model object and vice versa >>> >>> maybe pursuing some sort of 'Adapter' Model (chaining models >>> are not meant for this are they?). >>> you need an adapter for an adapter? >>> >>> On Thu, Nov 5, 2009 at 6:18 AM, Xavier López <xavilope@...> wrote: >>> >>> > Ok, I think that one has left you without words ;). I was only trying >>> to >>> > decouple in some way the 'conversion' of SimpleElementDTO to a String >>> done >>> > by the Model, maybe pursuing some sort of 'Adapter' Model (chaining >>> models >>> > are not meant for this are they?). >>> > After all, maybe I'll just stick to the ideal way of doing things, >>> > overriding detach() to get rid of superfluous properties, but I have to >>> say >>> > in some cases this may be kind of artifical... >>> > For example, if I have two radiochoices representing a single boolean >>> value >>> > (yes/no, with arbitrary labels), should I code a wrapper around Boolean >>> > with >>> > a description and a Boolean value in order to be able to cope with a >>> > suitable choiceRenderer ? >>> > >>> > Thanks for your time, >>> > Cheers ! >>> > >>> > 2009/11/4 Xavier López <xavilope@...> >>> > >>> > > Wonderful ! >>> > > >>> > > Now I understand better. If only I could set the String deptId in an >>> > inner >>> > > variable inside the Model and link it to the property with another >>> model >>> > ! >>> > > This comes from the fact that the building of the RadioChoice is made >>> > > inside a Helper Class... >>> > > >>> > > Probably this is an atrocity, but I hope it'll transmit the idea... >>> > > >>> > > Helper.java >>> > > ---------------------- >>> > > public static RadioChoice getDeptRadioChoice(String id){ >>> > > RadioChoice cr = new RadioChoice(id, >>> > > getDeptsAsDTOList(), >>> > > new SimpleElementChoiceRenderer()); >>> > > >>> > > Model crModel = new Model(){ >>> > > String id; >>> > > getObject(){ >>> > > return getDptDTO(id); >>> > > } >>> > > setObject(Object o){ >>> > > id = ( ((DTO) o).getId()); >>> > > } >>> > > }; >>> > > cr.setModel(crModel); >>> > > return cr; >>> > > } >>> > > >>> > > PersonForm.java >>> > > ----------------------------- >>> > > >>> > > RadioChoice cr = Helper.getDeptRadioChoice("deptId"); >>> > > cr.setModel(new Model(cr.getModel()){ >>> > > public Object getObject(){ >>> > > return >>> ((Model)super.getObject()).getObject(); >>> > > } >>> > > public void setObject(Object o){ >>> > > ((Model)getObject()).setObject(o); >>> > > p.setDeptId((String)m.getObject()); >>> > > } >>> > > }); >>> > > >>> > > Thanks ! >>> > > >>> > > >>> > > 2009/11/4 Pedro Santos <pedrosans@...> >>> > > >>> > >> Model crModel = new Model(){ >>> > >> getObject(){ >>> > >> return contextData.getDTO(p.getDeptId()); >>> > >> } >>> > >> setObject(Object o){ >>> > >> p.setDeptId( ((DTO) o).getId()); >>> > >> } >>> > >> }; >>> > >> >>> > >> On Wed, Nov 4, 2009 at 2:32 PM, Xavier López <xavilope@...> >>> > wrote: >>> > >> >>> > >> > Hi Sven, Pedro, >>> > >> > >>> > >> > Thanks both for your quick reply. >>> > >> > >>> > >> > Ideally you would just set a Department instance into your Person >>> > >> objects >>> > >> > >>> > >> > >>> > >> > the best way is you have your depid property of type Department >>> > >> > >>> > >> > This was the first approach to take into account, but the idea was >>> > >> > discarded >>> > >> > in benefit of SimpleElementDTO, in order to provide only the >>> necessary >>> > >> > information to Wicket Models, with the intention of not wasting >>> any >>> > >> memory >>> > >> > on PageMaps due to Department object serializations... Also, this >>> > >> > SimpleElementDTO would be reusable throughout the whole >>> application >>> > when >>> > >> > it's about Radio and DropDown Choices... >>> > >> > >>> > >> > write some specialized render >>> > >> > > >>> > >> > This kinda 'dirty-fix' idea was already crawling in my mind, >>> trying to >>> > >> come >>> > >> > out someway. Thanks for providing a concrete implementation. >>> > >> > >>> > >> > So, in the end I'm trying to provide a custom model. Something >>> like: >>> > >> > >>> > >> > Java >>> > >> > ------------------------ >>> > >> > final Person p; >>> > >> > >>> > >> > Model crModel = new Model(){ >>> > >> > getObject(){ >>> > >> > return p.getDeptId(); >>> > >> > } >>> > >> > setObject(Object o){ >>> > >> > // o is String! >>> > >> > p.setDeptId( (String) o); >>> > >> > } >>> > >> > }; >>> > >> > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new >>> > >> > ChoiceRenderer("id", "description")); >>> > >> > cr.setModel(crModel); >>> > >> > >>> > >> > But i'm stucking into the same error, as this Model it's kind like >>> a >>> > >> > PropertyModel which would be assumed by having the former >>> > >> > CompoundPropertyModel... >>> > >> > >>> > >> > Any thoughts ? Maybe rendering labels independently ? >>> > >> > >>> > >> > It's strange nobody has bumped into this situation before.. Maybe >>> it's >>> > >> > because i'm still thinking like I was using Struts... >>> > >> > >>> > >> > Thanks to both again, >>> > >> > Cheers ! >>> > >> > >>> > >> > >>> > >> > 2009/11/4 Pedro Santos <pedrosans@...> >>> > >> > >>> > >> > > Hi Sven, he stell can write some specialized render... but I >>> think >>> > the >>> > >> > best >>> > >> > > way is you have your depid property of type Department. Than all >>> > this >>> > >> > > thread >>> > >> > > would not have started :) >>> > >> > > >>> > >> > > class YourCustomRender >>> > >> > > { >>> > >> > > @Override >>> > >> > > public String getIdValue(Object object, int index) >>> > >> > > { >>> > >> > > if (object instanceof DTO) >>> > >> > > { >>> > >> > > return ((DTO)object).getDeptId() >>> > >> > > } >>> > >> > > else >>> > >> > > { >>> > >> > > return (String)object;//already is the depid >>> string >>> > >> > > } >>> > >> > > } >>> > >> > > >>> > >> > > @Override >>> > >> > > public Object getDisplayValue(Object object) >>> > >> > > { >>> > >> > > if (object instanceof DTO) >>> > >> > > { >>> > >> > > return ((DTO)object).getDescription(); >>> > >> > > } >>> > >> > > else >>> > >> > > { >>> > >> > > return contextData.getDTOBasedOnDepid(object); >>> > >> > > } >>> > >> > > } >>> > >> > > } >>> > >> > > >>> > >> > > On Wed, Nov 4, 2009 at 1:29 PM, Xavier López < >>> xavilope@...> >>> > >> wrote: >>> > >> > > >>> > >> > > > Hi, >>> > >> > > > >>> > >> > > > I have a question regarding the use of RadioChoice and >>> > >> ChoiceRenderer's >>> > >> > > in >>> > >> > > > conjunction with CompoundPropertyModel. I'm new to Wicket (but >>> > >> already >>> > >> > a >>> > >> > > > convinced user ;) ), so maybe my approach on this one is not >>> at >>> > all >>> > >> as >>> > >> > it >>> > >> > > > should be... Any comments are welcome ! >>> > >> > > > >>> > >> > > > I'll get into details. Let's say I have a class in my domain >>> model >>> > >> > named >>> > >> > > > Person. This entity has a property named 'deptId' of type >>> String. >>> > >> The >>> > >> > > > Person >>> > >> > > > entity is the backing for a CompundPropertyModel applied to >>> the >>> > >> whole >>> > >> > > form. >>> > >> > > > The 'deptId' field is inputted by the user, let's say, by >>> means of >>> > a >>> > >> > > > RadioChoice (I guess it makes no difference from a >>> DropDownChoice >>> > >> > taking >>> > >> > > > into account the point of the question). The choice list for >>> the >>> > >> > > > RadioChoice >>> > >> > > > component is a List made up of DTO objects with properties >>> "id" >>> > and >>> > >> > > > "description". To ensure proper rendering of labels, I use a >>> > >> suitable >>> > >> > > > ChoiceRenderer. >>> > >> > > > >>> > >> > > > Now, problems come when the 'deptId' property has a value in >>> the >>> > >> Person >>> > >> > > > entity used in the CompoundPropertyModel. I get an error >>> saying >>> > that >>> > >> > > class >>> > >> > > > String does not have any property called 'id' (I suppose this >>> > error >>> > >> > comes >>> > >> > > > from having a ModelObject of type String and also having a >>> > >> > ChoiceRenderer >>> > >> > > > refering to 'id' property). >>> > >> > > > >>> > >> > > > I'll provide some sample code: >>> > >> > > > >>> > >> > > > markup >>> > >> > > > ------------- >>> > >> > > > ... >>> > >> > > > <form wicket:id="form"> >>> > >> > > > ... >>> > >> > > > <span valign="top" wicket:id="deptId"></span> >>> > >> > > > ... >>> > >> > > > </form> >>> > >> > > > ... >>> > >> > > > >>> > >> > > > Java >>> > >> > > > ------------- >>> > >> > > > >>> > >> > > > ... >>> > >> > > > List<SimpleElementDTO> choices = contextData.getChoices(); >>> > >> > > > Person p = new Person(...); >>> > >> > > > Form f = new Form("form"){...}; >>> > >> > > > f.setModel(new CompoundPropertyModel(p)); >>> > >> > > > ChoiceRenderer cr = new ChoiceRenderer("deptId", choices, new >>> > >> > > > ChoiceRenderer("id", "description")); >>> > >> > > > f.add(cr); >>> > >> > > > ... >>> > >> > > > >>> > >> > > > >>> > >> > > > I suppose the 'normal' way of doing things would be providing >>> a >>> > >> custom >>> > >> > > > Model >>> > >> > > > to 'cr', but I'd like to know if there is a possibility to >>> achieve >>> > >> this >>> > >> > > > point still using CompoundPropertyModel... >>> > >> > > > >>> > >> > > > The stack trace I get is the following: >>> > >> > > > >>> > >> > > > WicketMessage: No get method defined for class: class >>> > >> java.lang.String >>> > >> > > > expression: id >>> > >> > > > Root cause: >>> > >> > > > org.apache.wicket.WicketRuntimeException: No get method >>> defined >>> > for >>> > >> > > class: >>> > >> > > > class java.lang.String expression: id >>> > >> > > > at >>> > >> > > > >>> > >> > > > >>> > >> > > >>> > >> > >>> > >> >>> > >>> org.apache.wicket.util.lang.PropertyResolver.getGetAndSetter(PropertyResolver.java:440) >>> > >> > > > at >>> > >> > > > >>> > >> > > > >>> > >> > > >>> > >> > >>> > >> >>> > >>> org.apache.wicket.util.lang.PropertyResolver.getObjectAndGetSetter(PropertyResolver.java:282) >>> > >> > > > at >>> > >> > > > >>> > >> > > > >>> > >> > > >>> > >> > >>> > >> >>> > >>> org.apache.wicket.util.lang.PropertyResolver.getValue(PropertyResolver.java:91) >>> > >> > > > at >>> > >> > > > >>> > >> > > > >>> > >> > > >>> > >> > >>> > >> >>> > >>> org.apache.wicket.markup.html.form.ChoiceRenderer.getIdValue(ChoiceRenderer.java:140) >>> > >> > > > at >>> > >> > > > >>> > >> > > > >>> > >> > > >>> > >> > >>> > >> >>> > >>> org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.getModelValue(AbstractSingleSelectChoice.java:144) >>> > >> > > > at >>> > >> > > > >>> > >> > > > >>> > >> > > >>> > >> > >>> > >> >>> > >>> org.apache.wicket.markup.html.form.FormComponent.getValue(FormComponent.java:797) >>> > >> > > > at >>> > >> > > > >>> > >> > > > >>> > >> > > >>> > >> > >>> > >> >>> > >>> org.apache.wicket.markup.html.form.RadioChoice.onComponentTagBody(RadioChoice.java:407) >>> > >> > > > at >>> > org.apache.wicket.Component.renderComponent(Component.java:2480) >>> > >> > > > at >>> > >> > >>> org.apache.wicket.MarkupContainer.onRender(MarkupContainer.java:1411) >>> > >> > > > at org.apache.wicket.Component.render(Component.java:2317) >>> > >> > > > at >>> > >> > > >>> > >> >>> org.apache.wicket.MarkupContainer.renderNext(MarkupContainer.java:1297) >>> > >> > > > ... >>> > >> > > > >>> > >> > > >>> > >> > > >>> > >> > > >>> > >> > > -- >>> > >> > > Pedro Henrique Oliveira dos Santos >>> > >> > > >>> > >> > >>> > >> > >>> > >> > >>> > >> > -- >>> > >> > "To err is human; to make real mess, you need a computer." >>> > >> > >>> > >> >>> > >> >>> > >> >>> > >> -- >>> > >> Pedro Henrique Oliveira dos Santos >>> > >> >>> > > >>> > > >>> > > >>> > > -- >>> > > "To err is human; to make real mess, you need a computer." >>> > > >>> > >>> > >>> > >>> > -- >>> > "To err is human; to make real mess, you need a computer." >>> > >>> >>> >>> >>> -- >>> Pedro Henrique Oliveira dos Santos >>> >> >> >> >> -- >> "To err is human; to make real mess, you need a computer." >> > > > > -- > "To err is human; to make real mess, you need a computer." > -- "To err is human; to make real mess, you need a computer." |
| Free embeddable forum powered by Nabble | Forum Help |