Hello,
This is
again a post about ADF Basics.
Today I am going to demonstrate a how we can set bindVariable in an Lov programatically without using viewAccessor of the viewObject.
For the
demonstration I have created a temporary viewObject and a department ViewObject
through which Lov will be made.
I have
created a TempVo with a Transient attribute EmployeeIdTrans on which lov of
EmployeesVO will be created .
In the
EmployeeVo I have created a viewCriteria as follows.
Then
apply the Lov on the basis of this EmployeeVO in the TempVO.
In the
viewAccessor of the lov Select the ViewCritera
Drag the
EmployeeIdTrans on the Jspx page and create a single selection lov.
Then add
a new Input text box from which we will fetch the value of the department on
which the lov needs to be filtered.
Here is
the code of the jspx page
<af:panelBox text="Set BindVariable in an Lov Programmatically" id="pb1"> <f:facet name="toolbar"/> <af:panelGroupLayout id="pgl1" layout="horizontal"> <af:inputText label="Department Id" id="it1" autoSubmit="true" value="#{viewScope.TestBean.deptId}"/> <af:button text="Set Department Id" id="b1" actionListener="#{viewScope.TestBean.setLovBindVarAL}"/> </af:panelGroupLayout> <af:spacer width="10" height="10" id="s1"/> <af:selectOneChoice value="#{bindings.EmployeeIdTrans.inputValue}" label="Employees" required="#{bindings.EmployeeIdTrans.hints.mandatory}" shortDesc="#{bindings.EmployeeIdTrans.hints.tooltip}" id="soc1" partialTriggers="b1"> <f:selectItems value="#{bindings.EmployeeIdTrans.items}" id="si1"/> <f:validator binding="#{bindings.EmployeeIdTrans.validator}"/> </af:selectOneChoice> </af:panelBox>
Then create a method in ApplicaitonModuleImpl that will set the value bindVariable and execute the lov and then call it in the bean.
/** * Method to execute Lov with bind variables * @param deptId */ public void setBindVarAndExceuteLov(Integer deptId){ Row currentRow = getTemp1().getCurrentRow(); RowSet lovVO = (RowSet)currentRow.getAttribute("EmployeesVO1"); lovVO.setNamedWhereClauseParam("DeptIdBind", deptId); lovVO.executeQuery(); }
You can
refer this if you want to know how to call a method to ApplicationModuleImpl in
Bean http://adfjavacodes.blogspot.com/2013/09/calling-method-defined-in-impl-class-of.html
Here is
the code used in the Bean.
package bindvariableinlovapp.view; import javax.faces.event.ActionEvent; import oracle.adf.model.BindingContext; import oracle.adf.view.rich.component.rich.input.RichInputText; import oracle.binding.OperationBinding; public class TestBean { private Integer deptId; public void setDeptId(Integer deptId) { this.deptId = deptId; } public Integer getDeptId() { return deptId; } public TestBean() { } public OperationBinding getBindings(String binding){ return BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding(binding); } public void setLovBindVarAL(ActionEvent actionEvent) { OperationBinding binding = getBindings("setBindVarAndExceuteLov"); binding.getParamsMap().put("deptId", deptId); binding.execute(); } }
On
filtering with department Id 1.
Here is the sample application : ProgramaticValueOfBindVarInLovApp
Here is the sample application : ProgramaticValueOfBindVarInLovApp
Is this not a duplicate post of
ReplyDeletehttp://adfjavacodes.blogspot.in/2014/04/adf-filtering-listofvalues-effectively.html ?
You have posted your own post again with different title ;)
haha... i didn't remember about the second section of the post..
ReplyDeleteAnyways, thanks for reminding me about this.. :)