• Lexington Holloway
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
can anyone please help me get the save button to work? Both cancel and Save and new button work but not the save button.

Here is my visual force page
<apex:page standardController="GCHFH_Rental_Partnership_Program__c" extensions="saveAndnew">
<apex:form >


<apex:sectionHeader title="GCHFH Rental/Parnetship Programs Edit" subtitle="New GCHFH Rental/Parnetship Program" />
<apex:pageBlock title="GCHFH Rental/Parnetship Programs Edit">
<apex:pageBlockSection title="General Information">

<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Date__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Tenant_Vendor__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Agreement_End_Date__c}"/>
     </apex:pageBlockSection>
     
     
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
 <apex:outputLabel value="Category"/>

 <apex:actionRegion >
                          <apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Category__c}">
                          
                          <apex:actionSupport event="onchange" reRender="ajaxrequest,ajaxrequest1" />
                          </apex:inputField>
                         </apex:actionRegion>
                          </apex:pageBlockSectionItem>
                          </apex:pageBlockSection>
                     
                         
                         <apex:outputPanel id="ajaxrequest">   
                  <apex:pageBlockSection rendered="{!GCHFH_Rental_Partnership_Program__c.Category__c=='GCHFH Building Space' || GCHFH_Rental_Partnership_Program__c.Category__c=='Habitat Home'}" >
                    <apex:pageBlockSection title="Rental program">
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Account__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Rent__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Rent_due_date__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Rent_Paid__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Street_GCH_Space__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.State__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.City__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Zip__c}"/>
</apex:pageBlockSection>
               </apex:pageBlockSection>
               
               
              </apex:outputPanel> 
                      
<apex:outputPanel id="ajaxrequest1">   
                  <apex:pageBlockSection rendered="{!GCHFH_Rental_Partnership_Program__c.Category__c=='E-paint program' || GCHFH_Rental_Partnership_Program__c.Category__c=='Urban Wood Program'}" >
                    <apex:pageBlockSection title="Partnership program">
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Donated_Item__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Expected_Value__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.share__c}"/>
</apex:pageBlockSection>
               </apex:pageBlockSection>

 </apex:outputPanel> 

<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>



<apex:commandButton action="{!Cancel}" value="Cancel"/>
<apex:commandButton action="{!saveAndNew}" value="Save & New"/>
</apex:pageBlockButtons>


</apex:pageBlock>

</apex:form>

 
</apex:page>

and this is my class for saveandnew. Do i have to write a new class for save or how do i get it to work?
public class saveAndnew {

   public ApexPages.StandardController scMain{get;set;}
      public saveAndnew(ApexPages.StandardController controller) {
       scMain = controller;



    }
public PageReference save() {
return null;
}

public PageReference saveAndNew() {
scMain.save();
PageReference GCHFHRental= new PageReference('/apex/GCHFHRental');
GCHFHRental.setRedirect(true);
return GCHFHRental;
}
}

 
has anyone found out how to put it a Save&New Button for a visualforce page? I cannot understand how to get this button to work or write the class that others have suggested
can anyone please help me get the save button to work? Both cancel and Save and new button work but not the save button.

Here is my visual force page
<apex:page standardController="GCHFH_Rental_Partnership_Program__c" extensions="saveAndnew">
<apex:form >


<apex:sectionHeader title="GCHFH Rental/Parnetship Programs Edit" subtitle="New GCHFH Rental/Parnetship Program" />
<apex:pageBlock title="GCHFH Rental/Parnetship Programs Edit">
<apex:pageBlockSection title="General Information">

<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Date__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Tenant_Vendor__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Agreement_End_Date__c}"/>
     </apex:pageBlockSection>
     
     
<apex:pageBlockSection >
<apex:pageBlockSectionItem >
 <apex:outputLabel value="Category"/>

 <apex:actionRegion >
                          <apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Category__c}">
                          
                          <apex:actionSupport event="onchange" reRender="ajaxrequest,ajaxrequest1" />
                          </apex:inputField>
                         </apex:actionRegion>
                          </apex:pageBlockSectionItem>
                          </apex:pageBlockSection>
                     
                         
                         <apex:outputPanel id="ajaxrequest">   
                  <apex:pageBlockSection rendered="{!GCHFH_Rental_Partnership_Program__c.Category__c=='GCHFH Building Space' || GCHFH_Rental_Partnership_Program__c.Category__c=='Habitat Home'}" >
                    <apex:pageBlockSection title="Rental program">
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Account__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Rent__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Rent_due_date__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Rent_Paid__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Street_GCH_Space__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.State__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.City__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Zip__c}"/>
</apex:pageBlockSection>
               </apex:pageBlockSection>
               
               
              </apex:outputPanel> 
                      
<apex:outputPanel id="ajaxrequest1">   
                  <apex:pageBlockSection rendered="{!GCHFH_Rental_Partnership_Program__c.Category__c=='E-paint program' || GCHFH_Rental_Partnership_Program__c.Category__c=='Urban Wood Program'}" >
                    <apex:pageBlockSection title="Partnership program">
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Donated_Item__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.Expected_Value__c}"/>
<apex:inputField value="{!GCHFH_Rental_Partnership_Program__c.share__c}"/>
</apex:pageBlockSection>
               </apex:pageBlockSection>

 </apex:outputPanel> 

<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>



<apex:commandButton action="{!Cancel}" value="Cancel"/>
<apex:commandButton action="{!saveAndNew}" value="Save & New"/>
</apex:pageBlockButtons>


</apex:pageBlock>

</apex:form>

 
</apex:page>

and this is my class for saveandnew. Do i have to write a new class for save or how do i get it to work?
public class saveAndnew {

   public ApexPages.StandardController scMain{get;set;}
      public saveAndnew(ApexPages.StandardController controller) {
       scMain = controller;



    }
public PageReference save() {
return null;
}

public PageReference saveAndNew() {
scMain.save();
PageReference GCHFHRental= new PageReference('/apex/GCHFHRental');
GCHFHRental.setRedirect(true);
return GCHFHRental;
}
}