You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by HHB <hu...@yahoo.ca> on 2009/05/19 15:16:22 UTC

Why I'm getting an empty list?

Hey,
This problem is really driving me crazy.
I have this panel that I want to set it as the 
content of a ModalWindow.
+++++++++++++++++++++
public abstract class GroupsPalettePanel 
    extends BasePanel {

    private ArrayList<Group> selectedGroups = 
                   new ArrayList<Group>();

    public GroupsPalettePanel(String id) {
        super(id);
        setOutputMarkupId(true);

        ChoiceRenderer renderer = 
                       new ChoiceRenderer("name", "name");
        final Palette groupsPalette = 
              new Palette("groupsPalette", 
              new Model(new ArrayList()),
              new GroupsModel(user), 
              renderer, 15, false);

        AjaxLink add = new AjaxLink("add") {
            @Override
            @SuppressWarnings("unchecked")
            public void onClick(AjaxRequestTarget target) {
                Iterator<Group> it = 
                groupsPalette.getSelectedChoices();
                    while (it.hasNext())
                        selectedGroups.add(it.next());
                onOk(target);
            }
        };
        add(groupsPalette);
        add(add);
    }

    public abstract void onOk(AjaxRequestTarget target);

    @SuppressWarnings("unchecked")
    public List<Group> getSelectedGroups() {
        return selectedGroups;
    }

}
+++++++++++++++++++++
And here is the father panel:
+++++++++++++++++++++
final ModalWindow groupsModal = new ModalWindow("groupsModal");
final GroupsPalettePanel groupsPanel = new
GroupsPalettePanel(groupsModal.getContentId()) {
     @Override
     public void onOk(AjaxRequestTarget target) {
        System.out.println("Selected Groups: " + 
            getSelectedGroups());
        groupsModal.close(target);
     }
};
+++++++++++++++++++++
The problem is when I select a group and click on the 
add button, the console shows that the selected choices 
are an empty list.
Any ideas why I'm getting this behavior?
Thanks.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org