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

Reply via email to