You need to sign in to do that
Don't have an account?
ShuchiM
Page url parameters become null on page refresh
Hi all
I am trying to return a value null in case a partial page refresh errors occurs due to some field not set correctly. The problem is, as soon as the refresh happens and the error is displayed in the message on the page, the page url does not have the record id in it.
e.g. Before the refresh:
na7.salesforce.com/TestPage?id=123456789383
After the refresh
na7.salesforce.com/TestPage
I guess this is a known behavior. Can someone please clarify? How can i avoid it or the right question is "should i avoid it?" ?
Regards
Shuchi
If you are using the standard controller, the id of the record that was originally passed on the URL can be accessed via the getId() method. Otherwise the best practice is to extract the parameterers from the URL in your controller constructor and store those in properties.
All Answers
As far as I'm aware, the only way that you can really avoid this is to carry out client side redirects every time. When you submit a form back, that hits the same page but with an HTTP POST request, which removes any parameters that were present for the original GET.
Is this causing you a particular problem?
If you assign your GET parameters to APEX Controller variables - they should stay intact for partial page refreshes.
Yes. The problem is that i return null after writing the error message. It still stays on the same page but the url changes. The user is now refreshing the page and as a result one of the field that uses the id starts throwing "Attempt to dereference null values"
If i add parameters using getParameters().put() in finally block, they show on the debug log, but they are not added to the url.
sigh :(
If you are using the standard controller, the id of the record that was originally passed on the URL can be accessed via the getId() method. Otherwise the best practice is to extract the parameterers from the URL in your controller constructor and store those in properties.
Cool ! I changed my method where i am recreating the url for PageReference (using id that i stored in a property, thanks @Bob) and returning that instead of null. That works !