我确定我犯了一个非常小的错误。我用代码创建了一个visualforce页面
<apex:page standardController="RuleCriteria__c" extensions="AW_RuleCriteriaController3">
<apex:form >
<apex:pageBlock title="Rule Criteria Detail">
<apex:pageBlockButtons >
<apex:commandButton value="Save" />
<apex:commandButton value="Save and New" />
<apex:commandButton value="Cancel" />
</apex:pageBlockButtons>
<apex:pageBlockSection title="Information">
</apex:pageBlockSection>
<apex:pageBlockSection columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Related Object"></apex:outputLabel>
<apex:selectList value="{!objType}" size="1" onchange="fieldNamesList(this.options[this.selectedIndex].value);">
<apex:selectOptions value="{!objOptions}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Field Name"></apex:outputLabel>
<apex:outputPanel id="fieldPanel">
<apex:outputPanel layout="block" styleClass="requiredInput">
<apex:outputPanel layout="block" styleClass="requiredBlock"/>
<apex:selectList value="{!fieldName}" size="1" onchange="setFieldApiName(this.options[this.selectedIndex].value)">
<apex:selectOptions value="{!fieldOption}"/>
</apex:selectList>
</apex:outputPanel>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Field Type"></apex:outputLabel>
<apex:outputPanel id="fieldTypeApiPanel">
<apex:outputText value="{! fieldType}"/>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputLabel value="Operator" />
<apex:outputPanel id="operatorPanel">
<apex:selectList value="{!newRuleCriteria.Matching_Type__c}" size="1" >
<apex:selectOptions value="{! Operator}" ></apex:selectOptions>
</apex:selectList>
</apex:outputPanel>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{! isPicklist}" id="picklist">
<apex:outputLabel value="Matching Value"> </apex:outputLabel>
<apex:selectList value="{!newRuleCriteria.Matching_Value__c}" size="1" >
<apex:selectOptions value="{! PickListValues}"/>
</apex:selectList>
</apex:pageBlockSectionItem >
<apex:pageBlockSectionItem rendered="{! isInput}" id='input1'>
<apex:outputLabel value="Matching Value"></apex:outputLabel>
<apex:inputFIeld value="{! newRuleCriteria.Matching_Value__c}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem rendered="{! isCheckBox}" id='check'>
<apex:outputLabel value="Matching Value"></apex:outputLabel>
<apex:inputCheckBox value="{! newRuleCriteria.Matching_Value__c}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:actionRegion >
<apex:actionFunction name="fieldNamesList" action="{!getFieldNames}" reRender="fieldPanel">
<apex:param assignTo="{!parentName}" value="" name="parentName"/>
</apex:actionFunction>
</apex:actionRegion>
<apex:actionRegion >
<apex:actionFunction name="setFieldApiName" action="{!setFieldApiName}" reRender="picklist,input1,check,operatorPanel,fieldTypeApiPanel">
<apex:param value="" name="fieldName"/>
</apex:actionFunction>
</apex:actionRegion>
</apex:form>
</apex:page>
扩展代码功能是这个
public pageReference setFieldApiName(){
fieldName = Apexpages.currentPage().getParameters().get('fieldName');
if(fieldName != null && fieldName.length() >0){
fieldType = Schema.getGlobalDescribe().get(objType).getDescribe().fields.getMap().get(fieldName).getDescribe().getType().name();
if(Schema.DisplayType.PickList == Schema.getGlobalDescribe().get(objType).getDescribe().fields.getMap().get(fieldName).getDescribe().getType())
{isPicklist=true;
isCheckBox = false;
isInput =false;
isMinMax = false;}
if(Schema.DisplayType.Boolean == Schema.getGlobalDescribe().get(objType).getDescribe().fields.getMap().get(fieldName).getDescribe().getType())
{isPicklist=false;
isCheckBox=true;
isInput= false;
isMinMax= false;
}
}else {fieldType='';
isMinMax=isCheckBox=isPickList=false;
isInput=true;
}
System.debug('pick list is '+isPickList);
return null;
}
在这个页面中的一个选择列表中,当用户选择标签时,我显示对象的标签,然后在第二个列表中,我显示与该标签相对应的字段,但是当我选择一个字段 actionFunction selectFieldApiName called.and 在调试日志中显示选择列表为真。但是没有选项列表正在呈现我认为在选择选项列表字段后 ispickList 变得真实,然后这个 pageblocksection 项目应该呈现
<apex:pageBlockSectionItem rendered="{! isPicklist}" id="picklist">
<apex:outputLabel value="Matching Value"> </apex:outputLabel>
<apex:selectList value="{!newRuleCriteria.Matching_Value__c}" size="1" >
<apex:selectOptions value="{! PickListValues}"/>
</apex:selectList>
</apex:pageBlockSectionItem >
但它不是渲染任何人都可以告诉我哪里错了。请帮忙!