function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Deepika Gupta 26Deepika Gupta 26 

Visualforce Link Issue

How can i create a link on one VF page that will navigate to another VF Page.I am able to that but its opening in new tab i want it on parent window just like popup.could anyone suggest how to solve this?
DeepthiDeepthi (Salesforce Developers) 
Hi Deepika,

If you require a modal popup to be displayed when you click on a command link then please check the below sample code:
 
<apex:page controller="ModalController">
    <apex:form >
        <apex:pageBlock >
           <apex:pageBlockTable value="{!leads}" var="led">
           <apex:column headerValue="Name">
           <apex:commandLink value="{!led.Name}" action="{!showpopup}" >
           <apex:param name="window" value="{!led.id}"/>
           </apex:commandLink>
          </apex:column>
           </apex:pageBlockTable>
        
 
        <apex:outputPanel id="tstpopup">
        <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}"/>
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">
           
            <apex:outputField value="{!ll.name}"/>&nbsp;&nbsp;
             <apex:outputField value="{!ll.Email}"/>&nbsp;&nbsp;
               <apex:outputField value="{!ll.company}"/>
               <apex:outputField value="{!ll.Phone}"/>
               
                 <br/>
                <apex:commandButton value="cancel" action="{!closePopup}" rerender="tstpopup"/>
            </apex:outputPanel>
        </apex:outputPanel>
 </apex:pageBlock>
    </apex:form>
 
    <style type="text/css">
        .custPopup{
            background-color: white;
            border-width: 2px;
            border-style: solid;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;
            top:100px;
           
        }
        .popupBackground{
            background-color:black;
            opacity: 0.20;
            filter: alpha(opacity = 20);
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            z-index: 9998;
        }

    </style>
</apex:page>
 
public with sharing class ModalController {

    public lead ll { get; set; }
    public Boolean displayPopUp { get; set; }
    public List<Lead> leads { get; set; }
   
    public ModalController(){
       leads=new List<Lead>();  
       ll=new lead();
       leads=[select Name,Email from Lead];
    }

    public PageReference closePopup() {
        displaypopup=false;
        return null;
    }
    
    public PageReference showPopup() {
    string ids=apexpages.currentpage().getparameters().get('window');
    ll =[select Name,Email,company,phone from lead  where id=:ids];
       displaypopup=true;
        return null;
    }



}

Hope this helps you!
Best Regards,
Deepthi