The CAF object “dropdown - single-select dropdown” requires an Option or Option Group of type “SelectItem”, which are usually generated automatically using a Content Provider of type “com.webMethods.caf.faces.data.object.BoundPropertiesSelectItemGroupProvider”, associated with a service result set.
I need to create a set of selections manually in CAF, but so far have not been able to create a result provider and manipulate its contents, such as:
Then, I created a class of my very own to store the items:
public class MyItem {
public String value;
public String label;
public MyItem() {}
public String getValue() {
return this.value;
}
public String getLabel() {
return this.label;
}
public void setLabel(String label) {
this.label=label;
}
public void setValue(String value) {
this.value=value;
}
}
Then in the view class I had to use my class to populate a List:
java.util.List list = new java.util.ArrayList();
MyItem item = new MyItem();
item.setLabel("label text");
item.setValue("value text");
list.add(item);
Then I added the list to the Provider:
this.resultProvider = new BoundPropertiesSelectItemGroupProvider(list, "item", "#{item.value}", "#{item.label}");
Finally I could bind the Option Group of the dropdown to the provider, and it works!
Thanks for this explanation - brilliant. Just a note to future generations: when you bind to this in your Option Group value, it (at least version 8.2) will show a warning saying:
Ignore this. A BoundPropertiesSelectItemGroupProvider falls into this category; it’s just a bug in the Designer warnings code.