aspose file tools*
The moose likes JSF and the fly likes commandLink with <rich:dataTable>, problem in pagination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "commandLink with <rich:dataTable>, problem in pagination" Watch "commandLink with <rich:dataTable>, problem in pagination" New topic
Author

commandLink with <rich:dataTable>, problem in pagination

Harpreet Parmar
Greenhorn

Joined: Nov 10, 2010
Posts: 9
Hi,

I am trying to use <h:commandLink> inside <rich:dataTable> and I am using <rich:datascroller> for pagination.
first column in the dataTable is displayed using <h:commandLink>.
The problem I am facing is that on the first page of dataTable, the links are working fine and the action method is getting called on click of the link.
But on any of the other pages, when i click any of the commandLink, the action method doesnt get called and the first page gets rendered on the UI.
I have tried changing the scope of my bean from request to session. I even tried changing the <h:commandLink> to <a4j:commandLink>. The only difference that <a4j:commandLink> makes is that, now instead of rendering the first page, nothing happens on click of commandLink on any of those pages. The first page works fine with <a4j:commandLink> also.
I have also verified that I am not using any nested forms.

This is what the code looks like:


I need the resolution urgently. Any help is appreciated.

Thanks in advance.

Thanks,
Harpreet Singh
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Hi Harpreet,

I know JSF can annoying in these matters, However probably there could be two reasons for this either you have a validation errors that prevents the execution of your action, or the getter method for your datatable doesn't return the same number of records during postback.
My guess is the second one, however to make sure it is not the first one please add h:messages to your page to display all validation errors.
If you are sure there is no validation errors, add more logs or try to debug your getter method in the post back (when you click the commandLink) and make sure it returns the same rows it displayed before (especially the same number of rows).

Enjoy


Sumeet Singh Aryan
Ranch Hand

Joined: Jul 30, 2008
Posts: 43
I strongly agree with Shafik.

Rather to use h:messages, you should use rich:messages with globalOnly="true": this displays all the Validation errors AJAX + NON AJAX and your are using rich:dataScroller so there may be a chance of AJAX errors.

PLease upload the code of your #{formActionsBean.results} method, as Shafik said, there may be a chance of error in this code.. also check the submittedValue and the Value attribute while clicking on the Pagination


The woods are lovely, dark and deep, But I have promises to keep; And miles to go before I sleep, And miles to go before I sleep. - Robert Frost
Sumeet Singh Aryan
Ranch Hand

Joined: Jul 30, 2008
Posts: 43
Try the following code.... what is your JSF Version and RichFaces Version???



I have added the <f:View>, <rich:columGroup> and <h:column>

I am using JSF 2.0 and RichFaces 3.3.3 and the richDatatable is working fine in my code.

Please try the code and let me know for further issues
Harpreet Parmar
Greenhorn

Joined: Nov 10, 2010
Posts: 9
Hi
Thanks for the replies. I tried putting <h:messages> and also <rich:messages>, but no error is displayed on the page.
I tried putting logs in the action method that returns the list to datatable, and it appears to be fine. There are currently 23 records in the list, and every time i click on any page number on the datascroller, the list returns exactly 23 results.

I tried the code given by Sumeet also but that also didnt work for me. I am using JSF 1.2 with Richfaces 3.3.3
I have tried using JSF 2.0 JARs also, still the problem persists.

Does anyone know anything else regarding this?

Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Hi Harpreet,

I tried putting logs in the action method that returns the list to datatable, and it appears to be fine.


It shouldn't be an action method it should be a getter method, please check the getter methods in post back does it return the same rows.
The problem could be your action method is fired after the getter is called especially during the decode phase.
Also posting your code is going to help.
Harpreet Parmar
Greenhorn

Joined: Nov 10, 2010
Posts: 9
Hi Shafik,

Yh thats a getter only, my bad. And it is returning the same number of rows on every click of any page number on dataScroller.

This is the code from FormActionsBean:


And this is the code from FormulaService (Using Hibernate here):


I am still stuck with this problem. Any help is highly appreciated.
Hany Shafik
Ranch Hand

Joined: Jun 21, 2008
Posts: 80
Not sure, but can you check whether or not the request parameters has command link id as one of it's parameters
Harpreet Parmar
Greenhorn

Joined: Nov 10, 2010
Posts: 9
Hi,

I figured out the root cause for the problem. As I am using facelets in my application, in my web.xml the facelets.BUILD_BEFORE_RESTORE was set to true:




Changing it to false, solved the problem. There is no proper documentation available for this parameter, but looking for more info about it, I found many people complaining about it as it causes problems with Ajax. So I think the combination of Richfaces with this parameter set to "true" was the main problem.

But I have found that if this param is set to false, then if the session times out, a ViewSessionExpired exception gets thrown.

Is there anyone who have any similar scenario?
It will be great if someone can share any insights about this param.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: commandLink with <rich:dataTable>, problem in pagination