You need to sign in to do that
Don't have an account?

custom list controller and pagination/pagesize resets URL parameters
This is twisted, but I'll try to lay it out. I've got a visualforce page being accessed via a URL button from the account page, with some parameters being added to the URL from the account. The page contains a list of custom object records related to the account, accessed via a custom list controller. I'm doing this because I want to use the standard controller for the custom objects (I'm updating them in the same screen), but the list has to be dynamic because it only shows those records related to the source account (so standard list controller isn't an option), and it works beautifully.
However I just implemented the simple Previous/Next pagination links and a selectList to set the pageSize, and discovered that they will reset the entire page to the base visualforce page URL without the parameters. I used those parameters to specify limits on the custom list controller. So the net result is something like this:
Mark
However I just implemented the simple Previous/Next pagination links and a selectList to set the pageSize, and discovered that they will reset the entire page to the base visualforce page URL without the parameters. I used those parameters to specify limits on the custom list controller. So the net result is something like this:
- Click URL button on account, new VF page is presented with the correct related records
- Click Previous/Next link, works fine, returning the pages of related records, BUT removes the params from the URL
- Change pageSize in the selectList to something else, rerenders the navigation links and the pageBlockTable
- Apparently causes my custom list controller to RESET and with the parameters removed, now I have a completely different set of records!
Mark
I believe I ran into something like this awhile back.
My solution was to move the prev/next paging links into actionFunctions and use partial page refresh to re-render only that portion of the page. The parent page still has its GET args, and if you construct your controller properly it should remember the initial state (loaded from the GET args) plus any changes you've made during your partial page refreshes.
Moving away from parsing your own GET args is a good thing (or, at least, it was for me).
-john
[edit] I should mention that adding a simple rerender to the previous/next links does maintain the URL. However something strange happens with getPageSize. The URL params are still present, but apparently they have been removed from my map variable and the query is re-run on calling getPageSize without those parameters, resulting in a different set of records being returned. Very strange.
Mark
Message Edited by MarkL on 11-25-2008 08:59 AM
If I un-comment the pageSize lines in the controller (which I think are clearly incorrect), the page loads just fine. However now we have a different problem. The ssc variable is directly instantiated in the constructor, meaning the state should be maintained and the query should not be re-run. But selecting a new size results in the map variable being cleared (tough to trap in the debug log) and the ssc query running again with Account__c = '', returning a very different record set. Apparently the constructor is being reloaded, but not consistently since the map is cleared (even though the parameters are still present in the URL).
If I get specific with it like below the same problem occurs, mapURLParams is cleared and ssc is re-run. So I'm going to remove the selection option now and the users will just have to get by with the default size=20 list.
Message Edited by MarkL on 11-25-2008 10:06 AM
Message Edited by MarkL on 11-25-2008 10:08 AM
You might want to avoid StandardSetController altogether - it seems quite buggy.
I was experimenting with using it to replace our own home-rolled pagers, but have found two bugs:
StandardSetController or QueryLocator ignores SOQL where clause [ link ]
and
StandardSetController getHasNextPage incorrect [ link ]
I won't be trying the StandardSetController again for a couple releases at least.
As an aside: Because Salesforce doesn't have a developer-accessible bug database [ link ], we have no way of knowing when they fix these except trying our own test cases again.
The "soql where clause" bug no longer reproduces, so either I was utterly clueless when I posted (always a possibility) or it somehow got side-effect-fixed in the patch release that went out last night.
>> Update - it does reproduce whenever StandardSetController.setPageSize() is called. I posted a video to that thread.
The other issue I reported - about the "getHasNextPage" being faulty - still reproduces but is a relatively minor bug that can probably be worked around in the controller.
Still hoping for a bug DB that we can view/access! I'm never sure if something I posted about / log a case about will get fixed really quickly, or if it will get no response at all (like this one) - in which case, I don't know if it's being worked on or not.
Message Edited by jhart on 11-26-2008 01:32 PM
As for the setPageSize() bug I am working on it right now but I do not expect to have a release vehicle for this until Spring '09 because we are essentially in lockdown for Winter '09 at this point... Looking for a workaround too...
Message Edited by dchasman on 11-27-2008 02:29 PM