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

Embedded VF errors with Page Layouts

I am able to embed the VF page I want into a custom controller, but its behavior is very weird.


I have a series of currency values that I am putting in a panel grid. The VF Code looks like this:


<apex:page standardController="Object__c" extensions="RevenueBookController">
   <apex:CommandButton action="{!save}" value="Update Revenue Book" rerender="thePanel" /> 
  <apex:form >
        <apex:outputPanel id="thePanel">
        <apex:panelGrid columns="6" id="theGrid" width="80%">
            <b>Revenue Types:</b> 
            <apex:outputText value="Month 1" id="Month1"/> 
            <apex:outputText value="Month 2" id="Month2"/>
            <apex:outputText value="Month 3" id="Month3"/>
            <apex:outputText value="Quarter" id="Quarter"/>
            <apex:outputText value="Total" id="Total"/>
            <apex:outputText value="Revenue: " id="Revenue"/>
            <apex:inputField value="{!Object__c.Revenue_Month1__c}"/> 
            <apex:inputField value="{!Object__c.Revenue_Month2__c}"/>
            <apex:inputField value="{!Object__c.Revenue_Month3__c}"/>
            <apex:inputField value="{!Object__c.Revenue_Quarter__c}"/>
            <apex:outputField value="{!Object__c.Revenue_Total__c}"/>

 When I go to the page it looks right - the input fields show up in a grid as expected. However, when I add a value to one of the input fields and hit the update button, the entire page refreshes within the VF section.

What I want to happen is to just have the outputpanel refresh with updated numbers in the Total field.


Its probably something obvious, but its stumping me. Any suggestions and solutions appreciated.

Ray DehlerRay Dehler

What does your save method inside RevenueBookController look like?


If you didn't override it or have it returning a non-null value, the page will refresh.  If it returns null, the desired result occurs -- that is it simply rerenders what you requested.





Here is the controller code

public with sharing class ObjectExtension 
        private Object__c Obj;
	public ObjectExtension(ApexPages.StandardController stdController) 
              this.Obj= (Object__c)stdController.getRecord();
              Obj = [select Revenue_Month1__c, Revenue_Month2__c, Revenue_Month3__c, 
    				Revenue_Quarter__c, Revenue_Total__c,
    				Free_Cash_Flow_Month1__c, Free_Cash_Flow_Month2__C,Free_Cash_Flow_Month3__c,
    				Free_Cash_Flow_Quarter__c, Free_Cash_Flow_Total__c,
    				ECommerce_Month1__c, ECommerce_Month2__c, ECommerce_Month3__c,
    				ECommerce_Quarter__c, ECommerce_Total__c
    		    from Object__c where id =];

        public PageReference save()
              update Obj;
              return null;

 The Total Values are formula fields that I want to update after the user adds values to the inputFields and updates the record with the button.


However, the Total values weren't updating. Not sure why. This is my first VF piece in a couple months so its probably something obvious I'm missing.


I found a way to get what I wanted to happen - instead of using the Controller at all, I just added '{!quicksave}' as the action for the commandbutton. The re-render then works as expected and the Total formula fields reflect the updated values. This will work for m purposes, but it seems like the original process should have worked. So either the update command wasn't firing (it was according to the debug log), the new value wasn't getting assigned to the field (I thought the inputField took care of that), or the re-render might not have been re-rendering, even though it was clearly assigned. I don't think any of those could be the problem.


Thanks for the response.