Cascading dropdowns in a table

Hi,

I have to display two dropdowns in a table where the possible values of the second depend on the selection in the first dropdown.

Usually I use content providers and option groups to provide the possible values of dropdown but here each row of the table might have a different set of possible values. I do not see a solution for that.

Any suggestions are highly appreciated.

Regards,
Mathias

After you make a selection in the first dropdown, you’ll need to refresh the second drop down.

I would recommend binding the second dropdown to an option group that you programatically build based on the first value.

In the samples (http://communities.softwareag.com/ecosystem/communities/public/Developer/webmethods/products/caf/codesamples/caf_samples.html?overview=/public/Developer/webmethods/products/caf/codesamples/index.html&overview-page=0).

Look at the wm_corecontrolstest web app, and the pagebean: DropDownPageBean.java for examples of how to build Options with Java.

Regards,
–mark

Hi,
thanks for your response. I had a look at the sample. That is how I would do it outside a table. But that is not exactly the problem I try to solve. I want to display the two dropdowns in a table.

Do you also have an idea for that.

Regards,
Mathias

Please see the attached sample project. I think the same techniques for inside a table as well, so i built out a quick sample.

Regards,
–mark
DynamicDropDownTables.zip (11 KB)

Hi,

thanks a lot for the very useful sample. That works fine.

So the trick is:

  1. Access the current row using
String vehicleType = (String)resolveExpression("#{sampleItem.vehicle}");
  1. Construct a DefaultSelectItemGroupProvider for each row:
DefaultSelectItemGroupProvider g = new DefaultSelectItemGroupProvider();
for (int index = 0; index < styles.length; index ++) {
   g.add(new DefaultSelectItemProvider(styles[index], styles[index]));
}

Thanks for the effort.

Regards,
Mathias