+ Start a Discussion
Paul.FoxPaul.Fox 

apex:detail rerender attribute

How do I rerender a component on the page after someone inline edits a detail section?

 

According to the docs I thought I could just specify an id in the rerender attribute of apex:detail

 

So in this page:

<apex:page standardcontroller="Account" extensions="AccountDetailController" tabStyle="Account" id="AccountPage">
	<apex:detail id="detail" relatedListHover="false" inlineedit="true" rerender="relatedlists"/>
    <c:PageBlockTableEnhancer targetPbTableIds="contracts" paginate="true" defaultPageSize="10" pageSizeOptions="10,20,50"/>
        
    <!-- Outputpanel for rerender (for inline editing) -->
    <apex:outputpanel id="relatedlists">
    {!Account.Name}
    </apex:outputpanel>
</apex:page>

I thought the Account.Name would update if someone inline edited it in the detail section above. But it doesn't seem to work that way. Can't really tell what the rerender attribute does.

 

Anybody know another way to refresh the outputpanel after inline editing is finished?

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

So, your requirement is to show the output panel after editing and saved the record. Isn't it?

 

So, you can have a boolean value in the value in the AccountDetailController you have as extensions.

 

Try the following method:

 

public class AccountDetailController{

        public boolean showPanel{get;set;}

        public account acc{get;set;}

         ............

   public AccountDetailController(ApexPages.StandardController control){

           acc = (Account) control.getRecord();

   }

 

   public void save(){

       insert acc;

       showPanel = true;

   }

..........

}

 

VF page:

<apex:page standardcontroller="Account" extensions="AccountDetailController" tabStyle="Account" id="AccountPage">
    <apex:detail id="detail" relatedListHover="false" inlineedit="true" rerender="relatedlists"/>
    <c:PageBlockTableEnhancer targetPbTableIds="contracts" paginate="true" defaultPageSize="10" pageSizeOptions="10,20,50"/>
        
    <!-- Outputpanel for rerender (for inline editing) -->
    <apex:outputpanel id="relatedlists" rendered="{!showPanel == true}">
    {!Account.Name}
    </apex:outputpanel>
</apex:page>

 

Hope this will help you...!

 

Please don't forget to give kudos by clicking on the Star icon and mark this as a solution, if this works out.

 

Paul.FoxPaul.Fox

I'm just trying to get the Outputpanel to show the new value.

 

Here's what happens now:

Open the visualforce page and change the account name and click save.

apex:detail shows new account name, outputpanel still shows previous account name.

 

I'd like the apex:outputpanel to refresh and show the new name.

Paul.FoxPaul.Fox

Here's a simpler version of the page that anyone can use to see the issue.

<apex:page standardcontroller="Account" tabStyle="Account" id="AccountPage">
	<apex:detail id="detail" relatedListHover="false" inlineedit="true" rerender="accountname" relatedlist="false"/>
    <apex:outputpanel id="accountname">{!Account.Name}</apex:outputpanel>
</apex:page>

 

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi Paul,

 

Anyhow you need to have the pagerefresh script in your page.

 

So, that you need an extension controller and a boolean value in it.

 

Try the following,

Vf page

<apex:page standardcontroller="Account" extensions="AccountDetailController" tabStyle="Account" id="AccountPage">   

     <<apex:outputPanel id="refresh1" rendered="{!refreshPage}">

         <script>

              window.top.location='/{!Id}';

         </script>

    </apex:outputPanel>

<br/>

<apex:detail id="detail" relatedListHover="false" inlineedit="true" rerender="relatedlists"/>
    <c:PageBlockTableEnhancer targetPbTableIds="contracts" paginate="true" defaultPageSize="10" pageSizeOptions="10,20,50"/>   //In this component you need to add thecontroller AccountDetailController and save buttton with the action="{!save}"
  </apex:page>

 

PageBlockTableEnhancer should have the follwoing outputpanel
    <!-- Outputpanel for rerender when save is done in the component-->
    <apex:outputpanel id="relatedlists" rendered="{!showPanel == true}">
    {!Account.Name}
    </apex:outputpanel>
</apex:page>

 

Controller

public class AccountDetailController{

        public boolean showPanel{get;set;}

        public boolean refreshPage{get;set;}

        public account acc{get;set;}

        ............

   public AccountDetailController(ApexPages.StandardController control){

           acc = (Account) control.getRecord();

   }

   public void save(){

       insert acc;

       showPanel = true;

       refreshPage = true;

   }

..........

}

 

 

Reason is you are accessing once you refresh only you will get the value modified in salesforce.

 

Hope this will help you...!

 

Please don't forget to give kudos by clicking on the Star icon and mark this as a solution, if this works out.

 

 

Paul.FoxPaul.Fox

Turns out I just needed to add the apex:form tag around the components. Kudos to Salesforce Premier Support for that answer.

 

Kudos for a creative solution though Kamatchi.

 

Here's the working page. The outputpanel rerenders as it should.

 

<apex:page standardcontroller="Account" tabStyle="Account" id="AccountPage">
<apex:form>
	<apex:detail id="detail" relatedListHover="false" inlineedit="true" rerender="accountname" relatedlist="false"/>
    <apex:outputpanel id="accountname">{!Account.Name}</apex:outputpanel>
</apex:form>
</apex:page>

 

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan
Thanks paul.