Skip to main content
Kory Howard (HSA Bank) 님이 #Visualforce에 질문했습니다
Hello,

The below code should show the Marketing_Request__c.Other_Channel__c inputField when a Marketing_Request__c.Channel__c of "Other" is selected, however it appears the page is not rerendering correctly. When a choice of "Other" is selected, the Other Channel inputField is never diplayed.

Any assistance resolving this is much appreciated.

<apex:page standardController="Marketing_Request__c">

<apex:sectionHeader title="Edit Marketing Request" subtitle="{!Marketing_Request__c.Name}"/>

<apex:form>

<apex:pageBlock title="Edit Marketing Request" id="thePageBlock" mode="edit">

<apex:pageMessages />

<apex:pageBlockButtons >

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

<apex:commandButton value="Cancel" action="{!cancel}"/>

</apex:pageBlockButtons>

<apex:pageBlockSection title="Branding and Channel" columns="1">

<apex:inputField value="{!Marketing_Request__c.Branding_Type__c}" required="true"/>

<apex:inputField value="{!Marketing_Request__c.Channel__c}" required="true">

<apex:actionSupport event="onchange" rerender="thePageBlock" immediate="true" status="channelStatus"/>

</apex:inputField>

<apex:actionStatus startText="applying change..." id="channelStatus"/>

<apex:inputField value="{!Marketing_Request__c.Other_Channel__c}" required="true" rendered="{!Marketing_Request__c.Channel__c == 'Other'}"/>

</apex:pageBlockSection>

</apex:pageBlock>

</apex:form>

</apex:page>

actionSupport rerender not working on inputField

 
답변 4개
  1. 2016년 1월 25일 오후 11:37
    Hey Kory

    when you try to rerender the pageblock entire block will be refreshed. Instead you only refresh part of the block.

    Please try this code and let me know if you have any problems

     

    <apex:page standardController="Marketing_Request__c">

    <apex:sectionHeader title="Edit Marketing Request" subtitle="{!Marketing_Request__c.Name}"/>

    <apex:form>

    <apex:pageBlock title="Edit Marketing Request" id="thePageBlock" mode="edit">

    <apex:pageMessages />

    <apex:pageBlockButtons >

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

    <apex:commandButton value="Cancel" action="{!cancel}"/>

    </apex:pageBlockButtons>

    <apex:pageBlockSection title="Branding and Channel" columns="1" id="pageBlockSection">

    <apex:inputField value="{!Marketing_Request__c.Branding_Type__c}" required="true"/>

    <apex:inputField value="{!Marketing_Request__c.Channel__c}" required="true">

    <apex:actionSupport event="onchange" rerender="pageBlockSection" status="channelStatus"/>

    </apex:inputField>

    <apex:actionStatus startText="applying change..." id="channelStatus"/>

    <apex:inputField value="{!Marketing_Request__c.Other_Channel__c}" required="true" rendered="{!Marketing_Request__c.Channel__c == 'Other'}" id ="otherChannelId"/>

    </apex:pageBlockSection>

    </apex:pageBlock>

    </apex:form>

    </apex:page>

    Thanks,

    pRAMODH.