webtier@glassfish.java.net

Re: CommandButton does not work in DataTable

From: <webtier_at_javadesktop.org>
Date: Thu, 21 Oct 2010 08:24:27 PDT

Ok, I have spend quite sometime debugging this. And I think I have more understanding on what is going on here.

I notice that whenever a button is pressed, it is recorded in the requestParameterMap.
During the ApplyRequestValuePhase, this button pressed is converted to an Action event which is enqueue to an event queue in the UIViewRoot.

Normally, this should be ok. But for a DataTable, it seems like during the restore phase there is no rows in the DataTable and the DataTable needs to get the rows again.

If it tries to get the rows during the ApplyRequestValuePhase, it will get nothing because the ManagedBean does not have all the required information to get the rows. Hence, no Action event will be created for the 'Edit' button pressed.

I found that one way to fix this is to use f:param in the command button to pass the search criteria information which is needed to build the rows. And add a method in the Managed Bean to get the search criteria information from the request parameters whenever it needs to get the rows.

After this two changes, it seems to work. But It seems more complicated than it needs to be. I guess it is more complicated maybe because I am using a request scope. If I use a view scope or higher then I properly will not have this problem.

I like to use the request scope so I am wondering is there any other better solution or cleaner solution. Or I am doing something incorrect here.

I also noticed that the method for getting the rows get called quite a lot of times, e.g. 3 times in ApplyRequestValuePhase, 3 times in ProcessValidationsPhase, 3 times in UpdateModelValuesPhase and 3 times in RenderResponsePhase. I did not look in to the details why it needs to call so many times.

Thanks
[Message sent by forum member 'wlmang']

http://forums.java.net/jive/thread.jspa?messageID=485869