There’s a mess with the selectManyCheckbox bindings: for both initial list items and selected items. ADF itself doesn’t support direct binding to a ViewObject, and that’s why, as Frank Nimphius said,
First off, the managed bean. It should contain fields with accessors for two lists: the initial options and the selected items.
The initialListItems will be bound to the multi-selection items element. Whilst the selectedItems list will contain the selected items from the initial list. The important thing is the datatype for the latter – a java.util.List! In fact it’s what provokes the “Unsupported Model Type” exception. This datatype hassle was actually the part that took me a real while to get it, I tried primitive array, ArrayList of String’s, Object’s and what not!
Now the only thing left is to bind both lists to the multi-selection component.
No more exceptions. That's it, hope it helps!
…you would need to use a managed bean to dispatch between the ADF binding layer and the multi select component.Maybe it’s just me, but it took me a while to figure out how exactly to do it.
First off, the managed bean. It should contain fields with accessors for two lists: the initial options and the selected items.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayList<javax.faces.model.SelectItem> initialListItems; | |
public ArrayList getInitialListItems() { | |
if(initialListItems == null) { | |
initialListItems = new ArrayList(); | |
JUIteratorBinding paramIter = | |
(JUIteratorBinding)JSFUtils.resolveExpression("#{bindings.ParamView1Iterator}"); | |
for(int i = 0; i < paramIter.getEstimatedRowCount(); i++) { | |
ParamViewRowImpl paramRow = (ParamViewRowImpl)paramIter.getRowAtRangeIndex(i); | |
SelectItem si = new SelectItem(); | |
si.setValue(paramRow.getParamkey()); | |
si.setLabel(paramRow.getParamvalue()); | |
initialListItems.add(si); | |
} | |
} | |
return initialListItems; | |
} | |
java.util.List selectedItems; | |
public void setSelectedItems(List selectedItems) { | |
this.selectedItems = selectedItems; | |
} | |
public List getSelectedItems() { | |
return selectedItems; | |
} |
The initialListItems will be bound to the multi-selection items element. Whilst the selectedItems list will contain the selected items from the initial list. The important thing is the datatype for the latter – a java.util.List! In fact it’s what provokes the “Unsupported Model Type” exception. This datatype hassle was actually the part that took me a real while to get it, I tried primitive array, ArrayList of String’s, Object’s and what not!
Now the only thing left is to bind both lists to the multi-selection component.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<af:selectManyCheckbox value="#{ManagedBean.selectedItems}"> | |
<f:selectItems value="#{ManagedBean.initialListItems}"/> | |
</af:selectManyCheckbox> |
No more exceptions. That's it, hope it helps!
No comments:
Post a Comment