【问题标题】:New page not opening with the help of pagereference在 pagereference 的帮助下无法打开新页面
【发布时间】:2014-08-18 13:18:27
【问题描述】:

我有一个 html 输入按钮,它在 VF 页面中调用一个 javascript 函数。执行 javascript 函数后,我想在新的顶点窗口中打开帐户的详细信息页面。为此,我写如下。

 <input type="button" value="Save" onclick="saveImage()"/>
 <apex:actionFunction name="savefn" action="{!saveData}" rerender="">
     <apex:param name="x" value="" assignTo="{!saveImageValue}" />
 </apex:actionFunction>
public void saveData()
{
    String accid,accName;
    for(Account a:[select id,name from Account where id=:account])
    {
        accid=a.Id;
        accName=a.Name;
    }
    //doing my stuff-----
    openDetailPage(account);
}

public PageReference openDetailPage(String acc) 
{ 
   /**Acc contains the id of the account in string format**/
   pageReference ref = new PageReference('/'+acc); 
   ref.setRedirect(true); 
   return ref; 
}

我可以调试 opendetailpage 日志,但无法打开该页面。谁能指出我做错了什么?

【问题讨论】:

  • 你的saveImage()函数在哪里需要在按钮点击时触发?

标签: javascript salesforce visualforce apex


【解决方案1】:

首先,您在 Visualforce 页面中引用为“SaveData”的函数在 Apex 代码中被命名为“SaveDataData”。

第二件事,“SaveData”是 void 类型。它需要返回一个页面引用。

public PageReference saveData()
{
... //skipping unchanged stuff
//doing my stuff-----
return openDetailPage(account);
}

【讨论】:

    猜你喜欢
    • 2018-08-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多