【问题标题】:Pass parameter from visualforce to apex Error将参数从 visualforce 传递到顶点错误
【发布时间】:2014-02-10 08:26:26
【问题描述】:

我有一个 visualforce 页面,我在表格中显示了我从 Apex 课程中获得的案例列表。

这是我的视觉力量:

<apex:page controller="XMLCasePopupController" title="Search" showHeader="false" sideBar="false" tabStyle="Case" id="page" >
<!-- messages -->
<apex:outputPanel id="top" layout="block">
<apex:outputLabel value="Possible duplicates" style="margin:20px; padding:10px; margin-top:10px; font-weight:bold; font-size: 1.5em;"/>
</apex:outputPanel>

<apex:form >
<apex:pageBlock title="XML Case Edit" id="XML_Case_Edit" mode="Edit">
  <!-- Buttons toolbar -->    
    <apex:pageBlockButtons >
        <apex:commandButton value="Finish" action="{!endCaseCreation}"/>
    <!--    <apex:commandButton value="Back" action="{!backStep}"/> -->
    </apex:PageBlockButtons>

    <apex:outputPanel id="page" layout="block" style="margin:5px;padding:10px;padding-top:2px;">
<apex:actionRegion >
  <!-- results panel -->
  <apex:outputPanel id="pnlSearchResults" style="margin:10px;height:350px;overflow-Y:auto;" layout="block">
      <apex:pageBlock id="searchResults">
         <apex:pageBlockTable value="{!results}" var="c" id="tblResults">
                <apex:column >
                <apex:facet name="header">
                    <apex:outputPanel >Release</apex:outputPanel>
                </apex:facet>
                <apex:outputLink onClick="test('{!c.Id}');return false;">{!c.Module_Release__c}</apex:outputLink>
                </apex:column>
</apex:column>
         </apex:pageBlockTable>
     </apex:pageBlock>
  </apex:outputPanel>
</apex:actionRegion>
</apex:outputPanel>
</apex:pageBlock>
<apex:actionFunction name="test" action="{!ShowCaseToTrue}">
    <apex:param name="param1" assignto="{!IdChosen}" value=""/>
</apex:actionFunction>
</apex:form>

所以我调用了 actionFunction ShowCaseToTrue 并且我想传递用户在表格中单击的案例的 ID。这是我的顶级课程:

public with sharing class XMLCasePopupController {

    public List<Case> results{get;set;} // search results
    public string searchString{get;set;} // search keyword
    public string caseId{get;set;}
    public Boolean ShowCase{get;set;}
    public Case ChosenCase{get;set;}
    public Id IdChosen{get;set;}

    public XMLCasePopupController() {
        // get the current search string
        searchString = System.currentPageReference().getParameters().get('lksrch');
        caseId = System.currentPageReference().getParameters().get('id');
        //ShowCase=False;
        System.debug('==> searchString = ' + searchString + ' -- caseid ' + caseId);
        runSearch(); 
    }

    // performs the keyword search
    public PageReference search() {
        runSearch();

        return null;
    }

    // performs the keyword search
    public void ShowCaseToTrue() {
        this.ShowCase=True;
        system.debug('El id que tengo que buscar es: '+ IdChosen);
        ChosenCase=[SELECT Id,CaseNumber FROM Case WHERE Id=:IdChosen];
    }
}

我总是在 IdChosen 中得到一个空值。有人可以帮我解决我在这里缺少的东西吗?

非常感谢!

安东尼奥

【问题讨论】:

    标签: javascript arguments salesforce visualforce apex


    【解决方案1】:

    几件事

    1)将IdChosen改为String数据类型

    public String  IdChosen{get;set;}
    

    2)改变动作功能测试

    <apex:actionFunction name="test" action="{!ShowCaseToTrue}">
       <apex:param name="param1" assignto="{!IdChosen}" value="{!c.Id}"/>
    </apex:actionFunction>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-01-08
      • 1970-01-01
      • 1970-01-01
      • 2013-06-14
      • 1970-01-01
      • 1970-01-01
      • 2019-10-05
      • 1970-01-01
      相关资源
      最近更新 更多