+ Start a Discussion

Problem with parts of page not refreshing after an error

I am using a visualforce page with a controller extension.  The page is called from a custom list button, so when the page is called, the id from the master object (object a) on the page is passed to the page as a parameter automatically by visualforce.


I have created a custom object (object b) which is linked to object a and the contact object via a master/detail relationship.  When I navigate to the page referenced above, I display a page block section asking the user to input the contact information.  Below that, I use the <apex:detail title="true"/> syntax to display object a detail from the object from which this page was called together with a title at the top of the page.


Under normal circumstances, this all works fine.


However, if there is an error in the entry of the contact, I get a page refresh which displays the page block section with the error message.  This message looks exactly as would be expected.  Unfortunately, the record detail block and the title do not refresh.  If I look at the address displayed at the top of the browser, the id of the original master object (object a) has been lost which would explain why the detail was not displayed.


Is this a bug or am I doing something wrong?  If it is a bug, is there some not too complex workaround?


Thanks for reading this and any help you migh be able to render.



Best Answer chosen by Admin (Salesforce Developers) 

I think I solved my own problem, although I don't quite understand why.


If I use this form of the apex detail statement:  

<apex:detail subject="{!$CurrentPage.parameters.id}" title="true" />, (wherein I added the subject keyword and parameter), it all seems to work just fine despite the fact that the id no longer appears in the URL for the error page in the address bar.  I suspect that some value is somehow retained by the controller.  I tried this technique because I noticed that the cancel button seemed to return to the correct page and thought that if the value was available to the cancel button, that it would be available to the detail statement on the vf page as well.