To open the URL in new Tab for PageReference, kindly use <apex:commandLink/>.
Sample Code:
Visualforce page:
<apex:page controller="Sample">
<apex:form >
<apex:pageblock >
<apex:commandlink action="{!switch}" target="_blank">
<apex:commandButton value="Switch"/>
</apex:commandLink>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Controller:
public class Sample {
public Sample() {
}
public pageReference switch() {
PageReference pageRef = new PageReference('http://www.google.com');
pageRef.setRedirect(true);
return pageRef;
}
}
Sample Code:
Visualforce page:
<apex:page controller="Sample">
<apex:form >
<apex:pageblock >
<apex:commandlink action="{!switch}" target="_blank">
<apex:commandButton value="Switch"/>
</apex:commandLink>
</apex:pageblock>
</apex:form>
</apex:page>
Apex Controller:
public class Sample {
public Sample() {
}
public pageReference switch() {
PageReference pageRef = new PageReference('http://www.google.com');
pageRef.setRedirect(true);
return pageRef;
}
}
Can anyone explain the code for accessing object from the controller method?
ReplyDeleteCheck this links for more info
Deletehttp://www.infallibletechie.com/2013/02/how-to-fetch-data-from-controller-and.html
http://www.infallibletechie.com/2013/02/how-to-fetch-data-from-controller-and_6.html
Cheers!!!
Can you explain how to navigate to a new page like this in service cloud console? I have an apex class that contains the code below. I need to modify it because it does not work in service cloud.
ReplyDeletereturn new PageReference('/apex/CustomVisualForcePage?id=' + objectId);
if you pass querystring paramter isdtp=vw, and set in visualforce page attributes showHeader={!IF($currentPage.parameters.isdtp==null,'true','false') same applies for sidebar. if you dont set these you will get page error visualforce page can't be displayed with in iframe security issue in service console.
ReplyDelete- Pawan
Worked perfectly... Thanks
ReplyDeleteJust what I was looking for. Works a treat. Thank you.
ReplyDeleteAwesome!
ReplyDeleteAll of the post are simple and very useful.Thank you.
ReplyDelete