How to get a comma-separated list of clients by doing a multi-select from an LOV dialog:
1. go to faces-config.xml
2. Search Page: Add search.jspx and create the page where you have an input box and a command button
3. LOV Dialog Page: Add lov.jspx and create a page
a. drag and drop the view from datacontrol palette to add an ADF table
b. through the table facets->selection of af:table in the structure pane, add the af:tableSelectMany
c. through the table facets->action of af:table in the structure pane, add a command button for the table
4. Using the ADF Dialog Framework: Inside the faces-config, add a jsf navigation case from the search page to the dialog, when the action is dialog:lov
5. Inside the search.jspx, add
a. partialTriggers="commandButton1" property for the input text box (InputText1)
b. action="dialog:lov", partialSubmit="true", returnListener="#{backing_search.returned}", useWindow="true" properties for the commandButton (commandButton1)6. Inside the backing bean search.java, add the following code to enter the returned value into the text box:
public void returned(ReturnEvent event){
if (event.getReturnValue() != null){
getInputText1().setSubmittedValue(null);
getInputText1().setValue(event.getReturnValue());
}
}
action="#{backing_lov.submit_action}"
8. Inside the lov.java (backing bean), enter the following code for the submit_action method
public String submit_action() {
// Add event code here...
Set selected;
StringBuffer selectedConsultants = new StringBuffer("");
CoreTable myTable = this.getTable1();
selected = myTable.getSelectionState().getKeySet();
for (Object rowKey: selected) {
myTable.setRowKey(rowKey);
Row rwdata = ((JUCtrlValueBindingRef) myTable.getRowData()).getRow();
// Include comma before the value only if there are existing values
if (selectedConsultants.length()==0){
selectedConsultants.append(rwdata.getAttribute(0));
} else {
selectedConsultants.append(","+rwdata.getAttribute(0));
}
}
System.out.println(selectedConsultants);
AdfFacesContext.getCurrentInstance().returnFromDialog(selectedConsultants, null);
return null;
}
This code will require some missing imports to be added so it works correctly.
7. Inside the lov.jspx, for the commandButton, add the action property