Page Lifecyle problems exposed by ObjectArrayDataProvider and isPostBack
Here's a senerio.
So you have a databound table. The table is bound to an object array using an object array data provider. Along with the table you also display some search criteria to use to narrow the results, and you wish to post back to the same page (postback) and redisplay the data according to the new search parameters. If you're trying to follow reasonable coding standards and keep the data in page scope, you will make the object array a page variable. If you're like me, you probably have some predefined idea of what the default search should be and you'd like to load that into the table when the user comes to the page.
This is a lot of functionality to code into one page, but JSF makes most of it very easy with the exception of one thing. The ObjectArrayDataProvider doesn't autorefresh and reloading it manually will be very difficult if you can't figure out if you're in a postback or not.
The problem is that the page scope methods available during the lifecycle are (in my oppinion) a pain in the neck to deal with. If you found this post after working through a situation similar to what I outlined above, you have also probably read alot about postbacks and how to detect them. After spending more than 20 hours on this, I'm convinced that the framework doesn't have a simple method for determining if you're in a postback.
Some users suggest that the best solution is to rewrite some classes that are used in the lifecycle to interecept requests and setup postback status. This will certainly work, but then you're stuck with various code that you have to maintain throughout new releases of the framework.
If you're looking for a quick, easy solution, here it is: Move the object that backs your ObjectArrayDataProvider to session scope (throw it in your default session bean implementation) and check to make sure it has been initialized in your page's init() method. That's the quick and dirty way to do it. It works great. However, you do have to deal with the fact that you're fattening up your session significantly by storing search result arrays in the session. So, simple solution, but fairly inefficient results.
In the future, it would be very nice if the JSF team would implment an isPostBack() method on the deault page bean that correctly determines the postback status in the init method. Then, you could load the page scope object array in the init method by simply checking if it's not a postback request, and reload your array in an action method when search parameters are provided.
I hope this is of use to someone.

