Wednesday, August 19, 2009

Af:Query bind variable workaround

When you try to enter a page that has af:query with bind variable, after ExecuteWithParams, it always keeps the first value that we first entered the page.
http://adfbugs.blogspot.com/2009/08/afquery-bind-variable-bug.html
Steve Muench said...
Filed bug# 8809022 with your testcase, thanks.
WORKAROUND----------
Rather than using the ExecuteWithParams action as the task flow'sinitial activity, instead write a custom AM method that you publishon the AM's client interface that does the following:
public void initTaskFlowDefinition(Number deptno) {
// Set var value on VO's variable
managergetEmployeesView1().ensureVariableManager().setVariableValue("inDepId",deptno);
// Save the save of the view criteria to "remember"
// the current var values as the ones to be restored
// in the search form.
getEmployeesView1().getViewCriteriaManager().getViewCriteria("EmployeesViewCriteria").saveState();
}
Then, have the task flow's default activity invoke this AMmethod instead to accomplish the task.

So i do it according to Steve workaround, but i didnt want to use bind variables since they have other issues:
http://adfbugs.blogspot.com/2009/07/jdeveloper-11-r1-cascading-lov-bugs.html
http://adfbugs.blogspot.com/2009/07/view-criteria-with-exists-optional-bug.html

So i used the following code:
public void initialSettings(oracle.jbo.domain.Number depId) {
EmployeesViewImpl emp = (EmployeesViewImpl)this.getEmployeesView1();
ViewCriteria vc = emp.getViewCriteria("EmployeesViewCriteria");
vc.first().setAttribute("DepartmentId", depId);
emp.getViewCriteriaManager().getViewCriteria("EmployeesViewCriteria").saveState();
}

i use this method in the task flow before entering the page and it seems to work fine.
Test Case:
http://adfbugs.googlecode.com/files/TestViewCriteria.zip

1 comment:

  1. Now I didn't even doubt that u will find workaround for this one ;)))))

    We tried and miserably failed at it so the lesson is:

    NEVER TRY, AND LET MICHAEL DO IT! :))))

    ReplyDelete