Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

h:inputHidden, h:dataTable, and request scope managed bean in JSF lifecycle

843842May 12 2006 — edited Mar 16 2007
I am having a bit of an issue working out the ordering of events when building a JSF page.

I have an object which has a collection of other objects within it (as well as other simple properties).

I have an h:dataTable in my JSP that wants to display the contents of that collection, and I have a managed bean which is used by h:dataTable. That managed bean is defined in faces-config.xml at the session scope.

I have the dataTable's managed bean lazily loading the contents of the properties and collection, but to do so I need the key value.

To get the key value, I inserted an inputHidden field into the JSP page, as follows:

<h:inputHidden value="#{user_comp.userId}" immediate="true"/>

user_comp is also a managed bean, defined in the faces-config.xml in the request scope.

What I thought would happen is that when the dataTable's managed bean requires the data, it could look in the requestMap for the other managed bean, find the bean and then its key value, and then load up the data, all in time for the dataTable's managed bean to use it.

However, I find that the getRowCount method on the DataModel is called before the user_comp userId property is set. I capture this error (and display it as a message) and return a 0 from getRowCount. The getRowCount method is called multiple times, and by the third time, the key value for user_comp is set, and so I can load the user_comp managed bean and return an accurate value from getRowCount. The screen seems to be fine after that, except for the error message displays.

Is there a way to force the setting of the user_comp property from inputHidden prior to the calls to the data model's getRowCount method?

Note: I am using MyFaces 1.1.

Thanks,
ken
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 13 2007
Added on May 12 2006
8 comments
253 views