[
https://issues.apache.org/jira/browse/WICKET-2465?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Igor Vaynberg updated WICKET-2465:
----------------------------------
Priority: Major (was: Blocker)
please submit a test case or a quickstart, or at least a snippet of your actual
usage.
it sounds like the problem may be that you are using the index instead of a pk
to identify your choices, but your choices model does not return a stable list.
eg one time it can return a,b,c,d and another a,c,d,b? hard to tell without
actual testcase or quickstart.
if you rely on the index to identify your items instead of some sort of other
pk then your list of choices must be stable.
> ListMultipleChoice - convertChoiceIdsToChoices
> ----------------------------------------------
>
> Key: WICKET-2465
> URL: https://issues.apache.org/jira/browse/WICKET-2465
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.4.1
> Environment: tomcat 6
> Reporter: Pedro Santos
>
> The method convertChoiceIdsToChoices on ListMultipleChoice has to converts
> submitted choice ids to choice objects.
> Bug: it do not resolve my second selection on component correctly.
> Ex: I have an list with items a, b, c, d.
> 1 - select item "a"
> 1.1 ListMultipleChoice component receive a collection, containing the choice
> "a" object, on model.
> 2 - select item "b"
> 2.1 ListMultipleChoice component receive an empty collection on model.
> simple debugging the component convertInput process, I do discover that the
> problem is occurring cause the method convertChoiceIdsToChoices is comparing
> an wrong 'old selected choice IdValue' with an 'right received choice id'. At
> line 291:
> if (getChoiceRenderer().getIdValue(choice,
> index).equals(ids[i]))
> the index variable passed to IChoiceRenderer, do not reflect the original
> index of the old choice, so the choice IdValue reached to old selection are
> wrong. The value reached id only his index on the "choices"( List variable).
> On this way, the comparison with "ids[i]", that reflect the 'right received
> choice id' fails.
> protected List<T> convertChoiceIdsToChoices(String[] ids)
> {
> ArrayList<T> selectedValues = new ArrayList<T>();
> // If one or more ids is selected
> if (ids != null && ids.length > 0 && !Strings.isEmpty(ids[0]))
> {
> // Get values that could be selected
> final List<? extends T> choices = getChoices();
> // Loop through selected indices
> for (int i = 0; i < ids.length; i++)
> {
> for (int index = 0; index < choices.size();
> index++)
> {
> // Get next choice
> final T choice = choices.get(index);
> if
> (getChoiceRenderer().getIdValue(choice, index).equals(ids[i]))
> {
> selectedValues.add(choice);
> break;
> }
> }
> }
> }
> return selectedValues;
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.