When building web applications with Oracle ADF and Struts like the ADF Toy Store example, there is a good reason why pages are set up by default to post-back to their related data action. As part of the default ADF DataAction lifecycle, any data contained in fields on the current page's submitted form need to first be applied to the matching bindings in the current page's binding container, and then the controller layer can decide what page to navigate to, if any.
When using HTML hyperlinks that do not link-back to the same data action that goes with the page -- effectively not following the post-back pattern -- you need to be careful that any parameter names that you might pass in the URL do not match the names of any bindings in the binding container of the page you are linking to. Doing so may cause unexpected results like what I'm about to describe.
I was working with a customer last week who had a master/detail JSP page (say DeptEmp.jsp) showing dept and summary emp information. Their page contained a hyperlink to allow the user to "drill down" to see more information on the employees in that department. It looked like this:
<a href="EmpDetails.do?Deptno=<c:out value='${bindings.Deptno}'/>" >More Info</a>
Since the current page is DeptEmp.jsp, all of the form submits and links from this page in general should post/link back to "DeptEmp.do" to follow the post-back pattern. However, this link was not and when the EmpDetails.jsp page would render, the user was sometimes seeing strange behavior. We tracked this down to the fact that the EmpDetails.jsp page contained a binding in its binding container named Deptno and this meant that the standard processUpdateModel() phase of the DataAction lifecycle for the EmpDetails data page was seeing the incoming Deptno parameter value with a matching name, and going ahead and updating the value of the Deptno binding with the value of this Deptno parameter passed in. The developer was not intending that linking to this drill-down page would update any data, but since the post-back pattern was not being used, this was an unintended side effect.
Forewarned is forarmed should you need to do this yourself. Avoid passing parameters with the same names as binding names in the target page to avoid unintentional model updating.
3:48:46 PM
|