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
Jason PaineJason Paine 

values on included header page not saving when I press save on parent page

I have a header page that I want to include on serveral pages.
This header has info such as name, phone,email, etc.

The other pages lead a user through a series of questions similar to a visual workflow.
As they go along the user may need to edit fields on either form.

If I edit data on the included header page then press a save button on the main pag;
my data is not saved back to the database.  or vice versa.

If a user enters or changes data on either the main page or the included page I want to be able to save data to both pages with one button click


I know I could copy and paste the code from the header page into all of my pages but would prefer not to do that.
As we may need to make changes to the header fields and I do not want to have edit  every page everytime we want to make a change.

I am including striped down versions of my pages and extension.
I tried to use apex:actionSupport to fire a save action on my main page but that did not work.

Any help or guidence would be great.

------------------exHeader Page-----------------------------------------
<apex:page standardController="Lead" extensions="exMyLeadExtension">
    <apex:form >
   
     <apex:pageBlock title="Demographics" mode="detail">
        <apex:pageBlockSection columns="3">
                <apex:inputField value="{!Lead.FirstName}"/>
                <apex:inputField value="{!Lead.LastName}"/> 
                <apex:inputField value="{!Lead.Phone}"/>
                <apex:inputField value="{!Lead.MobilePhone}" style="width:100px"/>
                <apex:inputField value="{!Lead.Email}" style="width:100px" />
           </apex:pageBlockSection>
   
    <apex:pageBlockButtons location="Bottom" >
        <apex:commandButton id="saveButtonHeader" action="{!quicksave}" value="Save" />
    </apex:pageBlockButtons>
       
</apex:pageBlock>
       
    </apex:form>
</apex:page>

------------------exPage1 Page-----------------------------------------
<apex:page standardController="Lead" extensions="exMyLeadExtension" docType="html-5.0" title="Page1">
<apex:include pageName="exHeader"/>
<apex:actionSupport event="onClick"
                    action="{!quickSave}"
                    rerender="Page1"/>
                           
<apex:form >
    <apex:pageBlock id="Page1" title="Page 1" mode="detail">
        <apex:pageBlockSection >
                <apex:inputField value="{!Lead.Street}" style="width:200px" />
                <apex:inputField value="{!Lead.City}" style="width:100px" />             
        </apex:pageBlockSection> 
       
    <apex:pageBlockButtons location="Bottom" >
        <apex:commandButton id="saveButtonPage1" action="{!quicksave}" value="Save" />
        <apex:commandButton id="nextPage2Button" action="{!nextPage2}" value="Save go Page2" />
    </apex:pageBlockButtons>
     
    </apex:pageBlock>          
    </apex:form>
</apex:page>

------------------exPage2 Page -----------------------------------------
<apex:page standardController="Lead" extensions="exMyLeadExtension" docType="html-5.0" title="Page2">
<apex:include pageName="exHeader"/>
<apex:actionSupport event="onClick"
                    action="{!quickSave}"
                    rerender="Page2"/>
                           
<apex:form >
    <apex:pageBlock id="Page2" title="Page 2" mode="detail">
        <apex:pageBlockSection >
                <apex:inputField value="{!Lead.State}" style="width:100px" />
                <apex:inputField value="{!Lead.PostalCode}"  style="width:100px" />
        </apex:pageBlockSection> 
       
    <apex:pageBlockButtons location="Bottom" >
        <apex:commandButton id="saveButtonPage2" action="{!quicksave}" value="Save" />
        <apex:commandButton id="nextPage1Button" action="{!nextPage1}" value="Return to Page1" />
    </apex:pageBlockButtons>
     
    </apex:pageBlock>          
    </apex:form>
</apex:page>

------------------exMyLeadExtension Extension-----------------------------------------
String name;
    Boolean showGreeting = false;
   
    private final Lead lead;
   
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public exMyLeadExtension(ApexPages.StandardController stdController) {
        this.lead= (Lead)stdController.getRecord();
      
       
    }
 
    public PageReference nextPage1() {
        update lead;
        PageReference pageRef= Page.exPage1;
        pageRef.setRedirect(true);
        pageRef.getParameters().put('id',Lead.id);
        return pageRef;
    }
     
  public PageReference nextPage2() {
        update lead;
        PageReference pageRef= Page.exPage2;
        pageRef.setRedirect(true);
        pageRef.getParameters().put('id',Lead.id);
        return pageRef;
    }
   

}

Ashish_SFDCAshish_SFDC
Hi Jason, 


Ofcourse copying the view state / values would be teh best option. 

Try the Floating/Sticky Headers For Visualforce PageBlockTable if that fits in, See the code and explanation in the blog below, 

http://www.redkitetechnologies.com/2013/03/floatingsticky-headers-for-visualforce-pageblocktable/


Regards,
Ashish