gpt4 book ai didi

javascript - 将参数从 Visualforce 传递到 apex 错误

转载 作者:行者123 更新时间:2023-11-28 08:32:29 24 4
gpt4 key购买 nike

我有一个 Visualforce 页面,我在其中以表格显示从 Apex 类(class)获得的案例列表。

这是我的视觉力量:

<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。这是我的顶点类(class):

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 中得到空值。有人可以帮我解决我在这里缺少的东西吗?

非常感谢!

安东尼奥

最佳答案

Couple of things

1)将IdChosen更改为String数据类型

public String  IdChosen{get;set;}

2)更改action功能测试

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

关于javascript - 将参数从 Visualforce 传递到 apex 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21672142/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com