18 September 2014

Different ways of setting bind variable value in ADF

Hi All,

Today we are going to see by how many ways you can set the bind variable value.

We can set the bind variable value by following methods:

1)  setNamedWhereClauseParam()

2) setVariableValue() of VariableValueManager

3) defineNamedWhereClauseParam()  


4) By Setter Method in ViewObjectImpl

Lets see all one by one.

1)  setNamedWhereClauseParam()

This is one of the method by which we can set the bind parameter value. This method will set the bind variable value for the default row set only.

You can use this method in following manner.

ViewObject vo = am.findViewObject("EmployeesVO1");
vo.setNamedWhereClauseParam("bind_emp", new Number(10));
vo.executeQuery();



2) setVariableValue() of VariableValueManager

This is the another way of setting bind variable value. This method will set the bind variable value for all row set.

You can use this method in following manner:

 ViewObject vo = am.findViewObject("EmployeesVO1");
 VariableValueManager vm = vo.ensureVariableManager();
 vm.setVariableValue("bindVariableName", value);
 vo.executeQuery();



3)  defineNamedWhereClauseParam() 

This method is used to set the bind variable value for those bind variable which are defined at run time as shown below:

ViewObject vo = am.findViewObject("EmployeesVO1");
vo.setWhereClause("EmployeesEO.FIRST_NAME= :bind_ename");
vo.defineNamedWhereClauseParam("bind_ename", null, null);
vo.setNamedWhereClauseParam("bind_ename", "nj");
vo.executeQuery();

In above example we have set the dynamic where clause and we have defined the dynamic bind variable with name bind_ename.


4) By Setter Method in ViewObjectImpl

In order to set the bind variable value by setter method you have to do the following steps:

a) Go to java section of your view object and generate the VOImpl class with check box check "Include bind variable accessors"
b) Then get the Instance of the VOImpl and call the setter method of that bind variable.

One thing here you can notice that it internally uses  setVariableValue method only.

That is all about setting bind variable value in ADF.

Happy Coding :)

6 on: "Different ways of setting bind variable value in ADF"
  1. Hi Kunal,
    I am having a use case where I am using 'Input List of Values' component for providing option to choose from a list of values. My data control is giving me the values 'WWD','PPO','SDO','UXP'...etc. During the runtime, the 'Input List of Values' component is showing first value 'WWD' in the textbox with option(search icon) to choose other values. My requirement is to display blank value(empty) the text field and when user clicks on search icon, the popup box should allow user to choose from that list. Please suggest the needful.
    Thanks

    ReplyDelete
  2. Thanks for great description. I have got a scenario on that uses POJO as VO. These Pojos do not have relations on business model side but in underlying platform which is LDAP based. on UI side I want to view them accordingly, for example if I click a row in role table the corresponding users in users table update. would you please help me on this scenario?
    Thanks

    ReplyDelete
  3. Amazing Article, thank you!. I am very glad to read your informative & practical blog. Kindly keep updating your blog.
    Java Developer is a wonderful career for IT students.To start Dream Career to become a Java developer learn from
    Java Training in Chennai
    . or learn thru Java Online Training from India .

    ReplyDelete
  4. Inspiring writings and I greatly admired what you have to say , I hope you continue to provide new ideas for us all and greetings success always for you..Keep update more information..

    Selenium training in Pune

    Selenium Online training

    Selenium interview questions and answers

    Selenium interview questions and answers

    Selenium Online training

    ReplyDelete