You need to sign in to do that
Don't have an account?
How to redirect a link to new tab using pagereference in apex.
i must use the action and rerender properties in command link.
this is my code:
Apex Page:
<apex:page sidebar="false" standardStylesheets="false" controller="LinkController">
<apex:outputPanel styleClass="app-icon" layout="block" id="app">
<apex:form >
<apex:commandLink action="{!Save}" reRender="app" value="rediff">
</apex:commandLink>
</apex:form>
</apex:outputPanel>
</apex:page>
public class LinkController {
public PageReference Save()
{
String newPageUrl = 'http://www.rediff.com/';
PageReference newPage = new PageReference(newPageUrl);
newPage.setRedirect(true);
return newPage;
}
}
Thanx in advance
Hi,
Try the below code:
/////////////////////// VF Pages ////////////////////////////////
<apex:page sidebar="false" standardStylesheets="false" controller="LinkController">
<apex:outputPanel styleClass="app-icon" layout="block" id="app">
<apex:form >
<apex:commandLink action="{!Save}" reRender="app" value="rediff" onclick="WindowNew()">
<script>
function WindowNew()
{
alert('abc');
window.open('http://www.rediff.com/');
}
</script>
</apex:commandLink>
</apex:form>
</apex:outputPanel>
</apex:page>
/////////////// Controller /////////////////////////
public class LinkController {
public PageReference Save()
{
String newPageUrl = 'http://www.rediff.com/';
return null;
}
}
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
its working.... but without using the onClick() or any other function. the action will be performed through the pagereference method.
when we call the Save() method in action then it automatically open a link in new page. commandlink must have the reRender property
also...
Thanks in advance......