我在这里停留在我呈现的论点上——我相当肯定我是从记录本身而不是从 visualforce 页面中提取值。当我将值 (are_you_kp__c) 从记录更改为“否”时 - pageblocksection 应该呈现,但由于某种原因它没有呈现。有人知道为什么吗?
我想我需要在这里进行一些控制器工作-但不确定从这里去哪里...
<apex:pageBlock title="New Bid" mode="maindetail" tabStyle="Proposal__c">
<apex:messages/>
<apex:actionRegion>
<apex:pageBlockSection columns="2" title="Bid Information" collapsible="false" showHeader="true">
<apex:inputField value="{!rfp.Bid_Amount__c}"/>
<apex:outputField value="{!rfp.Bid_Date__c}"/>
<apex:inputField value="{!rfp.Bid_Deliver_By__c}"/>
<apex:inputField value="{!rfp.Bid_Comments__c}"/>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Are you the Key Appraiser?"/>
<apex:outputPanel>
<apex:inputField value="{!rfp.are_you_kp__c}" required="true">
<apex:actionSupport status="StatusChange" event="onchange" rerender="PageErrors, appraiserInfo"/>
<apex:actionStatus startText="Updating page ..." id="StatusChange"/>
</apex:inputField>
</apex:outputPanel>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:actionRegion>
<apex:pageBlockSection title="Testing" columns="2" rendered="{!rfp.are_you_kp__c == 'No'}" id="appraiserInfo">
<apex:pageBlockSectionItem>
<apex:outputLabel value="Single Point of Contact" for="spoc"/>
<apex:selectList id="spoc" value="{!rfp.SPOCL__c}" size="1" title="Single Point of Contact Select">
<apex:selectOptions value="{!SPOCS}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
更新 - 使用正确的 id 将要渲染的元素包装在 outputPanel 中:由于 inputField 的更改,仍然存在切换渲染的布尔值的问题 - 我将如何在控制器中切换它?我想我需要评估 inputField 值是否 = 否,然后将渲染设置为 true - 我不确定如何......
<apex:outputPanel id="appraiserInfo">
<apex:pageBlockSection title="Testing" columns="2" rendered="{!rfp.are_you_kp__c == 'No'}">
<apex:pageBlockSectionItem>
<apex:outputLabel value="Single Point of Contact" for="spoc"/>
<apex:selectList id="spoc" value="{!rfp.SPOCL__c}" size="1" title="Single Point of Contact Select">
<apex:selectOptions value="{!SPOCS}"></apex:selectOptions>
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection></apex:outputPanel>
好吧,再试一次——这次它起作用了,但我不太明白为什么……只是它起作用了。这是除了将 action="{!updateAnswer}" 添加到上方(或下方,无论您以何种方式看到)的 actionSupport
public pageReference updateAnswer(){
if(this.p.are_you_kp__c == 'No')
rfp.are_you_kp__c = 'No';
try{
update rfp;
}
catch (DmlException ex){
ApexPages.addMessages(ex);
return null;
}
return null;
}
可能相关的控制器代码
public ProposalExtension(ApexPages.StandardController pCon) {
this.p = (Proposal__c)pCon.getRecord();
}