You need to sign in to do that
Don't have an account?
How to Refresh custom VF page after delete
Hello I have PageBlockTable with in line editing and a link to delete the selected row.
The delete works fine, however I cannot figure our how to refresh the page or even just the
pageblocktable to show that the row has been deleted.
Thanks in Advance
Delete method:
public string SelectedDetailId { get; set; }
public void DeleteDetail()
{
if (SelectedDetailId == null) {
return;
}
Product_Detail__c toBeDeleted = [SELECT name FROM Product_Detail__c WHERE Name = :SelectedDetailId LIMIT 1];
if (toBeDeleted != null) delete toBeDeleted;
//refreshTable();
}
Apex Code:
<apex:pageBlockTable id="annTable" value="{!AnnuityProducts}" var="item" Title="Annuity Detail">
<apex:column >
<a href="javascript:if (window.confirm('Are you sure?')) DeleteDetail('{!item.name}');" style="font-weight:bold">Del</a>
</apex:column>
<apex:column headerValue="Carrier">
<apex:outputField value="{!item.Name__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>
<apex:column headerValue="Type">
<apex:outputField value="{!item.Type__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>
<apex:column headerValue="Verified Assets">
<apex:outputField value="{!item.Asset_Total__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>
<apex:column headerValue="Portability">
<apex:outputField value="{!item.Portability__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>
<apex:column headerValue="Product Detail Name">
<apex:outputField value="{!item.Name}">
</apex:outputField>
</apex:column>
</apex:pageBlockTable>
<apex:actionFunction action="{!DeleteDetail}" name="DeleteDetail" reRender="test" >
<apex:param name="name" value="" assignTo="{!SelectedDetailId}"/>
</apex:actionFunction>
Hello
Thanks to everyone for there help. Based on Baktash H suggestion , the following code works!
public PageReference refreshTable() {
PageReference curPage = Page.DD_BOB;
curPage.getParameters().put('id', bob.id);
curPage.setRedirect(true);
return curPage;
}
All Answers
rerender the pageblocktable. in your actionfunction is the rerender attrubite 'test'. So the id of the pageblocktable has to be 'test'
Baktash
The id of the pageBlock in the above code is 'annTable'. I changed the reRender from 'test' to 'annTable'. Still no Refresh.
try putting the datatable in an actionregion tag.
I put the pageblockTable in the actionRegion tag and same results... no refresh.
Try putting the entire table in <apex:outputPanel id="panel">. Then refresh the panel.
Chris
Hello
This did not work either.
To refresh the whole page set the return type of the function to PageReference and redirect to the current page.
I added the following to my delete method shown above.
PageReference curPage = ApexPages.currentPage();
curPage.setRedirect(true);
return curPage;
I received the following error message when attempting to save....
"Error: Compile Error: Void method must not return a value at line 282 column 5"
When I change it from Void to Public ... the delete doesn't work. I receive other errors messages....
the return type of you method has to be PageReference.
public Pagereference methodName(){
PageReference p = new PageReference('/PageName');
p.setRedirect(true);
return p;
}
Hi, Surround your pageblock table with an <apex:outputpanel> </apex:outputpanel> tag and use that id of that panel and the pageblock Id in the rerender attribute of you <apex:actionFunction/>
You mean something like this
public PageReference refreshTable() {
PageReference curPage = ApexPages.currentPage();
curPage.setRedirect(true);
return curPage;
}
I receive no errors, but the page doesn't refresh either.
The output panel was suggested previously and did not work.
Here's the code for the output panel:
<apex:outputPanel id="panel">
<apex:pageBlockTable id="annTable" value="{!AnnuityProducts}" var="item" Title="Annuity Detail">
<apex:column >
<!-- <apex:outputLink title="" value="/{!row.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink> | -->
<a href="javascript:if (window.confirm('Are you sure?')) DeleteDetail('{!item.name}');" style="font-weight:bold">Del</a>
</apex:column>
<apex:column headerValue="Carrier">
<apex:outputField value="{!item.Name__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>
<apex:column headerValue="Type">
<apex:outputField value="{!item.Type__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>
<apex:column headerValue="Verified Assets">
<apex:outputField value="{!item.Asset_Total__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>
<apex:column headerValue="Portability">
<apex:outputField value="{!item.Portability__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
</apex:outputField>
</apex:column>
</apex:pageBlockTable>
</apex:outputpanel>
<apex:actionFunction action="{!DeleteDetail}" name="DeleteDetail" reRender="annTable,panel">
<apex:param name="name" value="" assignTo="{!SelectedDetailId}"/>
</apex:actionFunction>
Hello
Thanks to everyone for there help. Based on Baktash H suggestion , the following code works!
public PageReference refreshTable() {
PageReference curPage = Page.DD_BOB;
curPage.getParameters().put('id', bob.id);
curPage.setRedirect(true);
return curPage;
}