【问题标题】:reRender is not working as expected in visualforcereRender 在 vi​​sualforce 中没有按预期工作
【发布时间】:2013-03-12 07:40:43
【问题描述】:

我确定我犯了一个很小的错误。我用代码创建了一个 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 >

但它不是渲染,谁能告诉我哪里错了。请帮忙!!

【问题讨论】:

    标签: salesforce apex-code visualforce


    【解决方案1】:

    我想你想在这里使用的是&lt;apex:actionSupport&gt; 标签而不是&lt;apex:actionFunction&gt; 标签。将其嵌套在您的 &lt;apex:selectList&gt; 标记中。您要在此处使用的事件是 onChange。

    【讨论】:

      猜你喜欢
      • 2013-03-03
      • 2014-01-26
      • 2021-10-19
      • 2020-03-18
      • 2012-06-14
      • 2014-11-15
      • 1970-01-01
      • 2012-07-02
      • 2011-09-07
      相关资源
      最近更新 更多