Monday, December 27, 2010

ADF 11g - SelectOneChoice Values based upon another SelectOneChoice component independent of base datasource.

Requirement: ADF BC - Selectonechoice without base datasource create as per my earlier post. Now I need a second selectonechoice from DB without base datasource based upon the value selected in first SelectOneChoice.

Step1: Create the view object with bind variable (Value for this will be provided at run time).
Step2: Create a Executing With Parameter binding in page definition for this view.
Step3: In Executables section of PageDefinition create an iterator for this view object.
Step4: Create a list in bindings for specific attribute(similar to create list without basedatasource)
Step5: Drag and drop selectOncechoice from component pallete on JSF page. Bind it to the list which we created earlier.
Step6: Set the autosubmit of the first selectonechoice to true and partial trigger of second selectonechoice to first selectonechoice value.
Step7: Now create valuechangelistener for first selectonechoice and put below code.

public void RptYrMoSubValChg(ValueChangeEvent valueChangeEvent) {
Bindings bindings = getBindings();
if(soc1.getValue()!=null) {
tempIter=((DCBindingContainer)getBindings()).findIteratorBinding("SubmTypeLovIterator");
tempRow=tempIter.getRowAtRangeIndex(Integer.parseInt(soc1.getValue().toString()));
this.subType = tempRow.getAttribute("SubmTypeCd").toString();
System.out.println("Selected Submission Type"+subType);

operationBinding = bindings.getOperationBinding("ExecuteWithParams");
Object result = operationBinding.execute();
if (!operationBinding.getErrors().isEmpty()) {
System.out.println("ERROR");
}

}
}
}
public BindingContainer getBindings() {
return BindingContext.getCurrent().getCurrentBindingsEntry();
}