Re: [1.5.4] DropDownChoice is not presenting value if equals is not overwritten
I too received log warnings as mentioned in the newly-changed code mentioned above. My relevant Java code extract is: ChoiceRendererListChoiceItem crRenderer = new ChoiceRendererListChoiceItem(sName, nOrdinal); RadioChoiceListChoiceItem rcFieldsMode = new RadioChoiceListChoiceItem(rcFieldsMode, lciItems, crRenderer); rcFieldsMode.setRequired(true); frmForm.add(rcFieldsMode); My ListChoiceItem class is descended from Object but did not override equals(...) nor hashCode(). I now have done this and my warnings disappear. Excellent for the start of the weekend! Per Newgro wrote Thanks Sven, https://issues.apache.org/jira/browse/WICKET-4353 Cheers Per Am 24.01.2012 11:31, schrieb Sven Meier: Hi, Igor's commit statements says improved inconsistency handling in choice components. This change prevents IChoiceRenderer#getIdValue() being called with -1 as the index argument. I assume you are using a custom IChoiceRenderer which doesn't use the index but a custom identifier? Try overriding #getModelValue(): @Override public String getModelValue() { final Foo object = getModelObject(); if (object != null) { return + object.getBar(); } else { return ; } } And create a jira issue please. We might have to revert this change. Sven Am 24.01.2012 10:52, schrieb Per Newgro: Maybe a usecase helps :-) I load my choices in a LDM. The selected choice is located in the domain model. So the objects are equal by semantic but not by instance. Dropdown choices are lt;d, Germany; dk, Danmarkgt; hashcodes are 1 and 2 selected value is d, Germany hashcode is 3 Cheers Per Am 24.01.2012 10:42, schrieb Per Newgro: Hi, with 1.5.4 the implementation of org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.java has changed from code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code to code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); if (index 0) { // the model is returning a choice that is not in the available choices collection logger.warn( Detected inconsistency in choice component: {}/{}. Model returned object: {}, but this object is not available in the list of selected objects., new Object[] { getPage().getClass(), getPageRelativePath(), object }); // pretend like nothing is selected return ; } return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code I don't see why this changed. Release notes don't provide a task for that. But now i have to overwrite equals in my objects to get that to work. Is there another way of selecting the object? Thanks Per -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/1-5-4-DropDownChoice-is-not-presenting-value-if-equals-is-not-overwritten-tp4323310p4439341.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
[1.5.4] DropDownChoice is not presenting value if equals is not overwritten
Hi, with 1.5.4 the implementation of org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.java has changed from code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code to code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); if (index 0) { // the model is returning a choice that is not in the available choices collection logger.warn( Detected inconsistency in choice component: {}/{}. Model returned object: {}, but this object is not available in the list of selected objects., new Object[] { getPage().getClass(), getPageRelativePath(), object }); // pretend like nothing is selected return ; } return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code I don't see why this changed. Release notes don't provide a task for that. But now i have to overwrite equals in my objects to get that to work. Is there another way of selecting the object? Thanks Per - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: [1.5.4] DropDownChoice is not presenting value if equals is not overwritten
Maybe a usecase helps :-) I load my choices in a LDM. The selected choice is located in the domain model. So the objects are equal by semantic but not by instance. Dropdown choices are d, Germany; dk, Danmark hashcodes are 1 and 2 selected value is d, Germany hashcode is 3 Cheers Per Am 24.01.2012 10:42, schrieb Per Newgro: Hi, with 1.5.4 the implementation of org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.java has changed from code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code to code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); if (index 0) { // the model is returning a choice that is not in the available choices collection logger.warn( Detected inconsistency in choice component: {}/{}. Model returned object: {}, but this object is not available in the list of selected objects., new Object[] { getPage().getClass(), getPageRelativePath(), object }); // pretend like nothing is selected return ; } return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code I don't see why this changed. Release notes don't provide a task for that. But now i have to overwrite equals in my objects to get that to work. Is there another way of selecting the object? Thanks Per - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: [1.5.4] DropDownChoice is not presenting value if equals is not overwritten
Hi, Igor's commit statements says improved inconsistency handling in choice components. This change prevents IChoiceRenderer#getIdValue() being called with -1 as the index argument. I assume you are using a custom IChoiceRenderer which doesn't use the index but a custom identifier? Try overriding #getModelValue(): @Override public String getModelValue() { final Foo object = getModelObject(); if (object != null) { return + object.getBar(); } else { return ; } } And create a jira issue please. We might have to revert this change. Sven Am 24.01.2012 10:52, schrieb Per Newgro: Maybe a usecase helps :-) I load my choices in a LDM. The selected choice is located in the domain model. So the objects are equal by semantic but not by instance. Dropdown choices are d, Germany; dk, Danmark hashcodes are 1 and 2 selected value is d, Germany hashcode is 3 Cheers Per Am 24.01.2012 10:42, schrieb Per Newgro: Hi, with 1.5.4 the implementation of org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.java has changed from code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code to code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); if (index 0) { // the model is returning a choice that is not in the available choices collection logger.warn( Detected inconsistency in choice component: {}/{}. Model returned object: {}, but this object is not available in the list of selected objects., new Object[] { getPage().getClass(), getPageRelativePath(), object }); // pretend like nothing is selected return ; } return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code I don't see why this changed. Release notes don't provide a task for that. But now i have to overwrite equals in my objects to get that to work. Is there another way of selecting the object? Thanks Per - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: [1.5.4] DropDownChoice is not presenting value if equals is not overwritten
Thanks Sven, https://issues.apache.org/jira/browse/WICKET-4353 Cheers Per Am 24.01.2012 11:31, schrieb Sven Meier: Hi, Igor's commit statements says improved inconsistency handling in choice components. This change prevents IChoiceRenderer#getIdValue() being called with -1 as the index argument. I assume you are using a custom IChoiceRenderer which doesn't use the index but a custom identifier? Try overriding #getModelValue(): @Override public String getModelValue() { final Foo object = getModelObject(); if (object != null) { return + object.getBar(); } else { return ; } } And create a jira issue please. We might have to revert this change. Sven Am 24.01.2012 10:52, schrieb Per Newgro: Maybe a usecase helps :-) I load my choices in a LDM. The selected choice is located in the domain model. So the objects are equal by semantic but not by instance. Dropdown choices are d, Germany; dk, Danmark hashcodes are 1 and 2 selected value is d, Germany hashcode is 3 Cheers Per Am 24.01.2012 10:42, schrieb Per Newgro: Hi, with 1.5.4 the implementation of org.apache.wicket.markup.html.form.AbstractSingleSelectChoice.java has changed from code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code to code /** * @see FormComponent#getModelValue() */ @Override public String getModelValue() { final T object = getModelObject(); if (object != null) { int index = getChoices().indexOf(object); if (index 0) { // the model is returning a choice that is not in the available choices collection logger.warn( Detected inconsistency in choice component: {}/{}. Model returned object: {}, but this object is not available in the list of selected objects., new Object[] { getPage().getClass(), getPageRelativePath(), object }); // pretend like nothing is selected return ; } return getChoiceRenderer().getIdValue(object, index); } else { return ; } } /code I don't see why this changed. Release notes don't provide a task for that. But now i have to overwrite equals in my objects to get that to work. Is there another way of selecting the object? Thanks Per - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org