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;
public String account {get;set;}
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 ?
acc
- I do seeaccid
account
declared ? and how is it related to the actionFunction? You would be well-served by using better names -account
should represent an Sobject, acctId should represent an accountIdsaveData
functionallity to theopenDetailPage
method and call it directly from the action function.