To set the value of a bind variable programmatically, you will need to first get the
View Object where the bind variable is defined. Then from the
View Object you need to get access to the
VariableValueManager via the call ensureVariableManager(). Finally you need to call setVariableValue() on the VariableValueManager to set the bind variable to a specific value. Once all these are done, execute the View Object query with the new bind variable value by calling executeQuery() on the view as shown below.
Example:
ViewObjectImpl view = this.getSomeView();
VariableValueManager vm = view.ensureVariableManager();
vm.setVariableValue("bindVariableName", value);
view.executeQuery();
Context:
Application Module Implementation class
View Object Implementation class
Hi,
ReplyDeleteI use an other way :
ViewObjectImpl view = this.getSomeView();
view.setNamedWhereClauseParam("bindVariableName", value);
view.executeQuery();
Is there a better way than an other?
Clément
Hi Clement,
DeleteYour way is good becuase in main post i am unable to set bind variable value.
Maroof
Hi Clément
ReplyDeleteThe difference is that setNamedWhereClauseParam() will set the bind variable value for the default row set only. To make sure that the bind variable value is set for all row sets, use the View Object's VariableValueManager and call setVariableValue() on it instead. I suggest using the later to avoid calling setNamedWhereClauseParam() each time.
Congratulations Nick; It's an excellent article.
ReplyDeletewhat is this getSomeView() function??
ReplyDeleteFor each View Object (VO) that you add to the Application Module Data Model, you have a VO getter method. This is just an example that returns a VO object called "SomeView" for the sake of demonstrating this code bit.
Delete