Tell me more ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Here is my code the idea is when the user picks a value from the drop down i want to render siblings. I looked at http://wiki.developerforce.com/page/Visualforce_DynamicEditPage but i can't get mine to render the conditional part at the bootom (the 2nd close date)

Any ideas how to accomplish this? I don't want to nest them in a pageblockSection

        <apex:page standardController="Opportunity" sidebar="false">
        <apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/>
        <apex:form >
            <apex:pageBlock title="Edit Opportunity" id="thePageBlock" mode="edit">
                <apex:pageMessages />
                <apex:pageBlockButtons >
                    <apex:commandButton value="Save" action="{!save}"/>
                    <apex:commandButton value="Cancel" action="{!cancel}"/>                
                </apex:pageBlockButtons>
                <apex:actionRegion >
                    <apex:pageBlockSection title="Basic Information" columns="1">
                        <apex:inputField value="{!opportunity.name}"/>
                        <apex:pageBlockSectionItem >
                            <apex:outputLabel value="Stage"/>
                            <apex:outputPanel >
                                <apex:inputField value="{!opportunity.stageName}">
                                    <apex:actionSupport event="onchange" rerender="test"
                                                        status="status" />
                                </apex:inputField>
                                <apex:actionStatus startText="applying value..." id="status"/>
                            </apex:outputPanel>
                        </apex:pageBlockSectionItem>
                        <apex:inputField value="{!opportunity.amount}"/>
                        <apex:inputField value="{!opportunity.closedate}"/>
                    </apex:pageBlockSection>
                </apex:actionRegion>
                <apex:pageBlockSection title="Closed Lost Information" columns="1"
                                       rendered="{!opportunity.stageName == 'Closed Lost'}" id="test">
                    <apex:inputField value="{!opportunity.CloseDate}"  required="true"/>

                </apex:pageBlockSection>
            </apex:pageBlock>
        </apex:form>
    </apex:page>
share|improve this question
You should add an ID to the pageMessages tag and rerender that as well. I suspect that you aren't seeing an error which is occurring on the page. – Mark Pond Jan 18 at 21:10

2 Answers

The outputPanel with id=test does not render if at load the Stage is not Closed Lost. I don't believe it is possible to rerender an element (pageBlockSection in this case) which hasn't rendered when the page loaded. You would need to reRender a parent such as the pageBlock.

Here is a great blog post explaining this behaviour.

share|improve this answer

change your actionsupport as below as your action region encompasses other required fields which i believe are not getting validated:

<apex:actionSupport event="onchange" rerender="test, thePageBlock"
                                                        status="status" />

but it is better if you move the actionregion to include only the stage field (source) as below:

 <apex:pageBlockSection title="Basic Information" columns="1">
                        <apex:inputField value="{!opportunity.name}"/>
                        <apex:PageBlockSectionItem >
                         <apex:outputLabel value="Stage"/>
                         <apex:actionRegion >
                          <apex:inputField value="{!Opportunity.StageName}">
                          <apex:actionSupport event="onchange" reRender="test" />
                          </apex:inputField>
                         </apex:actionRegion>
                      </apex:PageBlockSectionItem>
                        <apex:inputField value="{!opportunity.amount}"/>
                        <apex:inputField value="{!opportunity.closedate}"/>
                    </apex:pageBlockSection>

                <apex:outputPanel id="test">
                <apex:pageBlockSection title="Closed Lost Information" columns="1"
                                       rendered="{!opportunity.stageName == 'Closed Lost'}">
                    <apex:inputField value="{!opportunity.CloseDate}"  required="true"/>

                </apex:pageBlockSection>
                </apex:outputPanel>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.