1

我有一份资产清单

Name:  column 2:  etc

A1      C1        b1
A2      c2        b2

当我点击 A1 时,我在里面调用 action="{!assetClicked}" 来做一些逻辑,但我不能将它重定向到另一个 Visual Force 页面如果我使用我可以链接到另一个 VF 页面,但不能做 action="{ !assetClicked}"

有没有办法将它们组合在一起或其他方式?

页面代码:

<apex:form >
  <apex:commandLink action="{! assetClicked}" value="{!wn.name}" id="theCommandLink"> 
    <apex:param value="{!wn.name}" name="id" assignTo="{!selectedAsset}" ></apex:param>
    <apex:outputLink value="/{!wn.id}" id="eventlink">{!wn.name}</apex:outputLink>
  </apex:commandLink> 
</apex:form>
4

3 回答 3

7

您将需要使用PageReference类。

这是文档中的一个修改示例:

// selected asset property
public string selectedAsset {get;set;}

public PageReference assetClicked() 
{
    // Your code here

    PageReference redirect = new PageReference('/apex/PageName'); 

    // pass the selected asset ID to the new page
    redirect.getParameters().put('id',selectedAsset); 
    redirect.setRedirect(true); 

    return redirect;
}

或者,您可以使用此处描述Page.PageName;的代替。new PageReference('/apex/PageName');

于 2012-02-01T17:06:34.290 回答
0

在按钮方法中,在方法末尾添加如下内容:

PageReference pr = new PageReference('/apex/YOUR_PAGE_NAME');

return pr;
于 2012-02-01T17:00:29.083 回答
0

您没有说明如何在目标 Visualforce 页面控制器中检索参数。我在另一个论坛找到了这个:

// Assuming the parameter is 'id' after redirecting to page2 you can retrieve the paramter thus
public customcontrollerpage2() {
    String ID = ApexPages.currentPage().getParameters().get('id');
}
于 2013-02-06T13:00:32.593 回答