1

enter image description hereI am trying to create a VF page with standard controller where first I will choose a value from picklist between 1 to 10 and based on that fields form my object will be displayed. The problem is I dont want to have two save buttons (one for number and one for the fields) can I rerender the fields section onchange of my picklist.

<apex:page standardController="RFP_Template__c" >
<apex:form >
    <apex:pageBlock >
    <apex:pageBlockSection id="numberofattachments">
        <apex:inputField value="{!RFP_Template__c.Number_Of_Attachments__c}" id="attachments" onchange="noofattachments(this.value);"/><br/>                       
        <apex:commandButton value="Save" reRender="AttachmentNames" action="{!save}"/>
        <apex:commandButton value="Cancel" action="{!cancel}"/>   
    </apex:pageBlockSection>
    <apex:pageBlockSection id="AttachmentNames">       
        <apex:inputField value="{!RFP_Template__c.Attachment_1_Name__c}" rendered="{!IF(VALUE(RFP_Template__c.Number_Of_Attachments__c) >= 1 , TRUE , FALSE)}"/> <br/>
        <apex:inputField value="{!RFP_Template__c.Attachment_1__c}" rendered="{!IF(VALUE(RFP_Template__c.Number_Of_Attachments__c) >= 1 , TRUE , FALSE)}"/> <br/>
        <apex:inputField value="{!RFP_Template__c.Attachment_2_Name__c}" rendered="{!IF(VALUE(RFP_Template__c.Number_Of_Attachments__c) >= 2 , TRUE , FALSE)}"/> <br/>
        <apex:inputField value="{!RFP_Template__c.Attachment_2__c}" rendered="{!IF(VALUE(RFP_Template__c.Number_Of_Attachments__c) >= 2 , TRUE , FALSE)}"/> <br/>           
        <apex:commandlink value="Save" action="{!save}" target="_parent" />                       
    </apex:pageBlockSection>
    </apex:pageBlock>    
</apex:form>    

7
  • Your question is not clear, maybe if you elaborate and add some screenshots. Would be helpful
    – Raul
    Commented Mar 3, 2017 at 12:12
  • i have added an image of my current page you can see there are two saves, first saves the number of attachments and based on that the below fields are rendered. and again save is present for saving the values in the fields. That I need to change
    – Afroz Kazi
    Commented Mar 3, 2017 at 12:23
  • Refer this example Commented Mar 3, 2017 at 12:26
  • but i am not using any controller
    – Afroz Kazi
    Commented Mar 3, 2017 at 12:38
  • @AfrozKazi Post your code Commented Mar 3, 2017 at 12:43

1 Answer 1

0

You should use OutputPanel and actionFunction to achieve this task. Refer below code:

<apex:page standardController="RFP_Template__c" >
<apex:form >
    <apex:pageBlock >
    <apex:actionFunction name="noofattachments" reRender="panel"/>
    <apex:pageBlockSection id="numberofattachments">
        <apex:inputField value="{!RFP_Template__c.Number_Of_Attachments__c}" id="attachments" onchange="noofattachments(this.value);"/><br/>                       

    </apex:pageBlockSection>
    <apex:outputPanel id="panel">
    <apex:pageBlockSection id="AttachmentNames">       
        <apex:inputField value="{!RFP_Template__c.Attachment_1_Name__c}" rendered="{!IF(VALUE(RFP_Template__c.Number_Of_Attachments__c) >= 1 , TRUE , FALSE)}"/> <br/>
        <apex:inputField value="{!RFP_Template__c.Attachment_1__c}" rendered="{!IF(VALUE(RFP_Template__c.Number_Of_Attachments__c) >= 1 , TRUE , FALSE)}"/> <br/>
        <apex:inputField value="{!RFP_Template__c.Attachment_2_Name__c}" rendered="{!IF(VALUE(RFP_Template__c.Number_Of_Attachments__c) >= 2 , TRUE , FALSE)}"/> <br/>
        <apex:inputField value="{!RFP_Template__c.Attachment_2__c}" rendered="{!IF(VALUE(RFP_Template__c.Number_Of_Attachments__c) >= 2 , TRUE , FALSE)}"/> <br/>           
        <apex:commandlink value="Save" action="{!save}" target="_parent" />                       
    </apex:pageBlockSection>
    </apex:outputPanel>
    </apex:pageBlock>    
</apex:form> 

6
  • but I need to eliminate the first save button. ie the save after the picklist
    – Afroz Kazi
    Commented Mar 3, 2017 at 13:09
  • yes it is working
    – Afroz Kazi
    Commented Mar 3, 2017 at 13:10
  • there are two issues i am encountering 1. the width of page inline shows hundred precent but is covering only half of the page 2. the labels of my input fields are not showing. I even used label tag. (P.s. I have used PanelGroups for inputfields )
    – Afroz Kazi
    Commented Mar 3, 2017 at 13:21
  • @AfrozKazi What are those issues? Commented Mar 3, 2017 at 13:22
  • 1. the width of page inline shows hundred precent but is covering only half of the page 2. the labels of my input fields are not showing. I even used label tag. (P.s. I have used PanelGroups for inputfields )
    – Afroz Kazi
    Commented Mar 3, 2017 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .