当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - New page not opening with the help of pagereference

问题描述:

I have a html input button which calls a javascript function in VF page. After execution of javascript function i want to open a detail page of an account in a new apex window. for that i am writing like below .

 <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;

}

I am able to debug out opendetailpage logs but i am unable to open the page. could any one point me where i am doing wrong ?

网友答案:

First thing, the function you reference as "SaveData" in the Visualforce page is named "SaveDataData" in the Apex code.

Second thing, "SaveData" is of type void. It needs to return a page reference.

public PageReference saveData()
{
... //skipping unchanged stuff
//doing my stuff-----
return openDetailPage(account);
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: