DropDownChoice behaving weird

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

DropDownChoice behaving weird

jiminssy
I am asked to take over something that a previous developer left off and it's causing me a grief.
Although I've done some web UI work before, I haven't worked with Wicket.
Unfortunately I don't have the time to read up a book and build things from scratch.
Could someone please help out if something is wrong in this picture.

Goal:
have a table with 3 columns each containing DropDownChoice, initially two on the right are disabled.
Choosing an option in the first one enables the second DropDownChoice with the chosen option removed.
Choosing an option in the second one enables the third DropDownChoice with the chosen option removed.

There is a AjaxFallBackDefaultDataTable.
One of the parameters to this table, an ArrayList<IColumn<T>> is passed.
There are three columns added to this ArrayList.
The code where the columns are added looks something like this

columns.add(new AbstractColumn<T>(new Model<String>("Column 1"))
{
     public void populateItem(Item cellItem, String id, IModel model)
     {
          cellItem.add(new CustomPanel(id, model, ...));
     }
});

CustomPanel extends org.apache.wicket.markup.html.panel.Panel
Inside the constructor of this CustomPanel, a DropDownList is instantiated and added to the panel.

DropDownChoice ddc = new DropDownChoice(id, model, data, renderer)
{
     protected boolean wantOnSelectionChangedNotifications()
     {
          return true;
     }

     protected void onSelectionChanged(Object newSelection)
     {
          this.setEnabled(false);    // for testing, to see if this drop down choice gets disabled
     }
};

There are 3 columns added in this fashion with one DropDownChoice added to them each.
However when I change one element the other 2 DropDownChoice change their selection as well.
Ideally the above test code should disable the DropDownChoice you've touched only.

Something is causing the 3 DropDownChoice's to be entagled and changing each others' selections.