You need to sign in to do that
Don't have an account?
BrettGus
Apex:commandLink not refreshing
I have a visualforce apex:commandLink that calls a method that deletes one of the records on the page. The delete method returns a null pagereference. However, the data on the page is not showing the delete unless I manually refresh. Is there a way around this?
Thanks
Hi BrettGus,
If I remember correctly, changing the end of your delete method from return null; to
should make it reload the current page.
Cheers,
Pat
All Answers
Hi BrettGus,
If I remember correctly, changing the end of your delete method from return null; to
should make it reload the current page.
Cheers,
Pat
That seems to have done it. Thanks
That did work, however, if after clicking a delete link, I click another one, I get an error about one of the variables on the page. I believe it has something to do with postback and redirect. Any ideas?
Deleting a record from the database doesn't remove the memory reference in your view state. Without some code, I honestly have no idea what your variable errors might mean. However, this is a fairly common scenario. Here's a typical solution:
In the page, I use a commandLink that calls the deleteAccount function, and provides a parameter for the selected account. In the controller, I generalize loading the list of records into a single function that is called once when the page loads, and once for each delete command (and I could have a refresh command, etc). I've used this technique numerous times, and it always works. Strictly speaking, unless you're leaving the page entirely, you don't need to redirect back to the page to cause a refresh.