Monday, March 23, 2009

Rationale behind ADF Faces isInitialRender flag deprecation

To those who might've been visiting my blog over past few months:

I'm back after a long break. I had some health issues which needed to be taken care of in late November and most of December 2008. And since then, I had gotten incredibly busy with day-to-day work that left no time for blogging. So much so, that I didn't even have time to visit my own blog page to find out visitor patterns, check for user comments etc. I notice that the first user comment for this blog had been posted back in December 2008, which I haven't had chance to reply to. Hope to get to it very soon.


Now that that's out of the way, the purpose of this post was to explain one of the points which had been touched upon in an earlier post of mine. In it, I mentioned AdfFacesContext function isInitialRender not functioning correctly, notwithstanding its usage discouraged in the Javadoc.

I finally got to the bottom of why its usage is discouraged, why it doesn't work as per Javadoc description and why it doesn't matter. One sentence summary is:

DO NOT USE THIS FUNCTION!!!

Not only is it deprecated, it doesn't work and shouldn't be expected to work. What is that all about, why is this function there in the first place? I am cutting and pasting the reasoning I received from the authoritative source behind this (as much as possible quoting verbatim, with slight contextual modifications):

ADF doesn't have any available method to know that you are rendering a page or page fragment for the first time. Instead, it is recommended that the user use task flow method-call activities to accomplish any kind of "initial render" setup before forwarding the page for rendering. The complication is that if you have UI components in the page that perform lazy data fetching, the page will actually render using two separate HTTP requests (one for the initial page, and another one for the lazy data fetch). There is no way that ADF Faces currently exposes to detect if you are in the "lazy data fetch" request. So, in general there is no way to know if a page or page fragment is being rendered the first time.

There you have it. Reiterating: Do not use the isInitialRender() function.

No comments: