+ Start a Discussion
Navjeet Singh 6Navjeet Singh 6 

How to open new tab in visualforce page

hii..
I have a button on the click of button output show in same tab , I want on the click of button output display a new tab without using java script?
plz help me...
 
=============It's my visualforce page code :- =============

<apex:page standardController="Opportunity" extensions="quickaction">
<apex:form >
<style>
.test{

float:right;

}
</style>

<div class='test'>
<apex:commandButton action="{!call}"  image="/resource/trac_QuickActions/Phone.png"/>
<apex:commandButton action="{!email}" image="/resource/trac_QuickActions/Mail.png"/>
<apex:commandButton action="{!meeting}" image="/resource/trac_QuickActions/Calendar.png"/>
<apex:commandButton action="{!task}" image="/resource/trac_QuickActions/Notes.png"/>
</div>
</apex:form>
</apex:page>

=========It's my apex code:-==========

public class quickaction {

    public String p;
    public String Name1;
    public quickaction(ApexPages.StandardController controller) {
 
 p = ApexPages.currentPage().getParameters().get('id');
 
 integer n=[SELECT Count() FROM OpportunityContactRole WHERE OpportunityId =:ApexPages.currentPage().getParameters().get('id') AND IsPrimary = true];
 system.debug(Name1+'nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn');
 
 if(n > 0){
 
 OpportunityContactRole op=[SELECT ContactId FROM OpportunityContactRole WHERE OpportunityId =:ApexPages.currentPage().getParameters().get('id') AND IsPrimary = true];
 
 Contact c=[select Name,id From Contact where Id=:op.ContactId ];
 
 Name1=c.Name;
 
 system.debug(Name1+'nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn');
 
 }
 
 
 
    }

public PageReference task(){

 PageReference acctPage = new PageReference('/00T/e?who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&tsk4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year()+'&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
        return acctPage;

}

public PageReference email(){
if(Name1 != null){
 PageReference acctPage = new PageReference('/00T/e?title=Call&who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&00N7A000000NoRh=Communication&tsk5=Email&00N7A000000NoRm=Email&tsk4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year()+'&tsk12=Completed&tsk2='+Name1+'&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
        return acctPage;
        }
        else{
         PageReference acctPage = new PageReference('/00T/e?title=Call&who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&00N7A000000NoRh=Communication&tsk5=Email&00N7A000000NoRm=Email&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
        return acctPage;
        
        
        }
}
public PageReference call(){
if(Name1 != ''){
 PageReference acctPage = new PageReference('/00T/e?title=Call&who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&00N7A000000NoRh=Communication&tsk5=Call&00N7A000000NoRm=Call&tsk4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year()+'&tsk12=Completed&tsk2='+Name1+'&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
        
        return acctPage ;
}
else{

 PageReference acctPage = new PageReference('/00T/e?title=Call&who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&00N7A000000NoRh=Communication&tsk5=Call&00N7A000000NoRm=Call&retURL='+ApexPages.currentPage().getParameters().get('id'));
        acctPage.setRedirect(true);
     
        return acctPage ;




}
}
public PageReference meeting(){
if(Name1 != null){
 PageReference acctPage = new PageReference('/00U/e?who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&ent=Event&retURL= '+ApexPages.currentPage().getParameters().get('id')+'&evt5=Meeting Booked with '+Name1+'&evt4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year()+'&evt2='+Name1);

        acctPage.setRedirect(true);
        return acctPage;
}
else{

 PageReference acctPage = new PageReference('/00U/e?who_id='+userinfo.getuserid()+'&what_id='+ApexPages.currentPage().getParameters().get('id')+'&ent=Event&retURL= '+ApexPages.currentPage().getParameters().get('id')+'&evt5=Meeting&evt4='+system.today().month()+'/'+system.today().day()+'/'+system.today().year());

        acctPage.setRedirect(true);
        
        return acctPage;


}

}
}
Keshab AcharyaKeshab Acharya
This will help.

https://developer.salesforce.com/forums/?id=906F000000096XFIAY
SujilaSujila
You can change apex:commandButton to apex:commandLink and use target attribute(_blank)