In this article, I'm trying to explain how can ViewObject attributes be read pro-grammatically and display these attributes in ADF Shuttle component.
The ADF Shuttle component is appropriate for when the business process requires sequencing selected objects for further action, and the user needs to see the source data and items selected for process. The above scenario can be useful when you want to compare two objects, where in user can quickly add and remove items from the pool. Here database table column will be displayed as comparable fields.
You can download the sample workspace from here
[Runs with Oracle JDeveloper 11.1.2.0.0 (11g R2) + HR Schema]
Implementation steps
Create a Fusion Web Application, click on ADF Business Components and create business components from table based on Employees. Create a CompareAttributes.java class file and add the below code.
Open the AppModule.xml and goo to Java tab in AppModule and click on edit java options. Generate the application module class: AppModuleImpl.java and open the AppModuleImpl.java file and the below method code.
The ADF Shuttle component is appropriate for when the business process requires sequencing selected objects for further action, and the user needs to see the source data and items selected for process. The above scenario can be useful when you want to compare two objects, where in user can quickly add and remove items from the pool. Here database table column will be displayed as comparable fields.
You can download the sample workspace from here
[Runs with Oracle JDeveloper 11.1.2.0.0 (11g R2) + HR Schema]
Implementation steps
Create a Fusion Web Application, click on ADF Business Components and create business components from table based on Employees. Create a CompareAttributes.java class file and add the below code.
public class CompareAttributes {
private String columnName;
private String columnAliasName;
public CompareAttributes() {
super();
}
public CompareAttributes(String columnName, String columnAliasName) {
super();
this.columnName = columnName;
this.columnAliasName = columnAliasName;
}
public void setColumnName(String columnName) {
this.columnName = columnName;
}
public String getColumnName() {
return columnName;
}
public void setColumnAliasName(String columnAliasName) {
this.columnAliasName = columnAliasName;
}
public String getColumnAliasName() {
return columnAliasName;
}
}
Open the AppModule.xml and goo to Java tab in AppModule and click on edit java options. Generate the application module class: AppModuleImpl.java and open the AppModuleImpl.java file and the below method code.
/**
* This method reads the ViewObject attributes and populate CompareAttributes list
* @return CompareAttributes list
*/
public List getCompareAttributes() {
ViewObjectImpl vo = getEmployeesView1();
ViewAttributeDefImpl[] attrDefs = vo.getViewAttributeDefImpls();
int count = 0;
List compareAttrs = new ArrayList();
for (ViewAttributeDefImpl attrDef : attrDefs) {
byte attrKind = attrDefs[count].getAttributeKind();
//checks attribute kind for each element in an array of AttributeDefs
if (attrKind != AttributeDef.ATTR_ASSOCIATED_ROW && attrKind != AttributeDef.ATTR_ASSOCIATED_ROWITERATOR) {
String columnName = attrDef.getName();
String columnAliasName = attrDef.getAliasName();
compareAttrs.add(new CompareAttributes(columnName, columnAliasName));
count++;
}
}
return compareAttrs;
}
Go back to AppModuleImpl.java and select Java tab in client interface section move getCompareAttributes from available to selected block.
In ViewController project, create index.jspx page and generate page definition page. Go to bindings tab and insert methodAction as "getCompareAttributes" from AppModuleDataControl.
Create the managedBean as "IndexBean", set the scope as pageFlowScope and copy the below code.
public List getShuttleList() {
BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
OperationBinding operBind = bindings.getOperationBinding("getCompareAttributes");
List<CompareAttributes> compareAttr = (List)operBind.execute();
List shuttleList = new ArrayList();
for (int i = 0; i < compareAttr.size(); i++) {
CompareAttributes attr = compareAttr.get(i);
SelectItem item = new SelectItem(i, attr.getColumnName(), attr.getColumnAliasName());
shuttleList.add(item);
}
return shuttleList;
}
Open index.jspx page and from component palette drag and drop the Shuttle Component, In Insert shuttle window for "Bind to list (select items) bind to #{pageFlowScope.IndexBean.shuttleList}" as shown below.
Run the index.jspx page, now user can quickly add and remove items from the pool.
Thanks this was helpful.
ReplyDelete