我被困在我在这里呈现的参数 - 我相当积极,我从记录本身拉动值,而不是从visualforce页面。当我将记录中的值(are_you_kp__c)更改为“No”时 - pageblocksection应该呈现,但由于某种原因它不会。有人知道为什么吗?Salesforce(Visualforce):重新渲染 - 从页面拉取值,而不是记录?
我想我需要在这里有些控制器的工作 - 但不知道从哪里何去何从......
<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>
更新 - 包裹在outputPanel与正确的ID将要呈现的元素:还有问题切换我的呈现布尔作为一个inputField的变化的结果 - 我将如何在控制器中切换此?我想我需要,如果inputField价值评估=否,并设置由渲染为真 - 我不知道怎么样,但...
<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>
好的多一个尝试 - 这一次它的工作原理,但我不明白为什么...只有它。这是除了加入行动=“{!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();
}
真棒发布和良好的说明 - 但我认为我的问题是现在我想我需要一个action = {!function}给我的actionSupport,可以评估用户选择的inputField的picklist值 - 并使用THAT切换我的“渲染”。我怎么去写一些东西给我的控制器扩展,可以做到这一点? are_you_kp__c是与--None--,Yes或No.的选项列表,并且如果他们回答否......那么我需要呈现该SPOC部分 – tsalb
感谢您的更新 - 但由于我尚未提交任何内容切换我的选择列表 - 我玩了一下,出于某种原因,我在那里的代码有效。但我不确定我是否明白为什么。 – tsalb
''将在选取列表更改时触发控制器上的操作。您没有使用'',因此''中的所有内容都将被发送回控制器,然后使用最新值重新呈现相关页面部分。 –