function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ABakABak 

Refreshing/Reloading a visualforce page

I have a Visualforce page where I am displaying some records in a pageBlockTable. I have the delete and edit links in a column .

 

My problem is that when we click delete it does execute the actionfunction in my controller and deletes the record but I want it to refresh the page as well. I dont know how to refrersh/reload the page through the controller.

 

I tried using javascript using window.location.reload()  and calling it right after my delete funciton in the tag itself but its reloading the page before the delete takes place.

 

Heres the pageBlocktable code 

 

<apex:pageBlockTable id="pbTable" var="row" value="{!maintenanceLineItems}" rendered="{!showMaintenanceTable}">
            	<apex:column headerValue="Action" width="50">
				<a 
href="javascript&colon;EditMaintenanceLineItemEntries('{!row.maintenanceLineItem.Id}');" style="font-weight:bold">Edit</a>&nbsp;|
					<a href="javascript&colon;if(window.confirm('Are you Sure?'))DeleteMaintenanceLineItemEnteries('{!row.maintenanceLineItem.Id}');" style="font-weight:bold">Del</a>
	         	</apex:column>

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
ABakABak

got it 

 

 

PageReference p = new Apexpages.Standardcontroller(opp).view();

p.setRedirect(true);    

return p;

 

here the opp would be the object linked to the standard controller. 

All Answers

imuino2imuino2

Add the reRender attribute to the actionFunction and assign it your pageBlockTable id

 

<apex:actionFunction reRender="pbTable" .......... />

 

Ignacio.

ABakABak

I tried to reset dataProvider to the list by deleting the deleted item from that variable (the one thats bound to the value prop of pageBlocktbale) and also set the reRender attribute on the actionfunciton but it still wont work.

 

 

imuino2imuino2

Did you try to reset the var that is populating the table???? cause if it doesnt refresh on delete then you will show the same data as the first time.

ABakABak

Thanks thats nice as it does the partial page refresh but my problem is a little more than that. My visualforce page is an extension of  the standard opportunity page which means I have a standard controller="Opportunity' and an extension controller as well. 

I can certainly update my page view by partial page refresh as you mentioned but it also does some recalc based on the trigger thats fired which updates some standard opp fields and that wont be reflected by going down this way. Thats y i think reloading the whole page is the solution to this. Any ideas?

imuino2imuino2

Why dont you use PageReference to redirect the whole page to itself?

You can find out about PageReference in this doc http://www.salesforce.com/us/developer/docs/apexcode/index.htm

 

Ignacio.

ABakABak

got it 

 

 

PageReference p = new Apexpages.Standardcontroller(opp).view();

p.setRedirect(true);    

return p;

 

here the opp would be the object linked to the standard controller. 

This was selected as the best answer