reRender在visualforce中没有按预期工作

时间:2013-03-12 07:40:44

标签: salesforce apex-code visualforce

我确信我正在做一个非常小的错误。我创建了一个带代码的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被调用,并在调试日志中显示 选择清单是真的。 但是没有选项列表正在渲染 我认为在选择了一个选项列表字段后,ispickList变为true,然后这个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 >

但它不是渲染可以任何人请告诉我哪里错了。请帮助!!

1 个答案:

答案 0 :(得分:0)

我认为您在这里使用的是<apex:actionSupport>标记,而不是<apex:actionFunction>标记。将其嵌套在<apex:selectList>标记中。您要在此处使用的事件是onChange。

相关问题