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
gbu.varungbu.varun 

Popup window by Apex code

Hi All,

 

Is there any way to open a pop-up by web service or Apex class??

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

This is possible. Try the following example,

 

VF page:

<apex:page controller="EgPOPupCon">
   <!-- Popup styling starts here -->    
    ..........................
   <!-- Popup to show while an opportunity is created ENDING-->
    <apex:pageblock >    
        <apex:pageblockSection rendered="{!INPUT == true}">
            <apex:inputtext value="{!name1}"/>         
            <apex:commandbutton value="Save" action="{!showpop}" />
        </apex:pageblockSection>       
        <apex:pageblockSection rendered="{!INPUT == false}">
            <apex:outputtext value="{!name1}"/>           
        </apex:pageblockSection>
    </apex:pageblock>   
  </apex:form>
</apex:page>

 

 

Apex Class:

public class EgPOPupCon{
    public Opportunity opp{get;set;}
    public boolean INPUT{get;set;}
    public boolean pop{get;set;}
    public string name1{get;set;}

    public EgPOPupCon(){       
           INPUT = true;
    }    
    public pageReference save(){     
       pop = false;
       input = false;
       opp = new Opportunity(name = name1, stagename = 'Prospecting', closedate = Date.today());
       insert opp;      
       PageReference nextpage1 = new PageReference('/apex/EgPOPup');
       return nextpage1.setRedirect(true);                
    }
    public void showpop(){        
       pop = true;
    }    
    public void reject(){        
       pop = false;
    } 
}

 

You can modify the page and controller as you would like to do as per your requirement.

 

Hope so this helps you...!

 

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.

 

gbu.varungbu.varun

Hi Kamatchi,

 

I have to open a page by apex class. This class is not associated with any VF. 

Kamatchi Devi SargunanathanKamatchi Devi Sargunanathan

Hi,

 

Then try the following,

 

VF page:

<apex:page > 
<apex:form > 
           <apex:commandButton value="Open SecondVF"  onclick="window.open('apex/SecondVF','popUpWindow','height=200,width=400,left=100,top=100');"  />
  </apex:form>
</apex:page>

 

SecondVF page:

<apex:page>

    welcome this is simple popup window..!

</apex:page>

 

You can modify the page and controller as you would like to do as per your requirement.

 

 

Hope so this helps you...!

 

Please mark this answer a Solution and please give kudos by clicking on the star icon, if you found this answer as helpful.

 

gbu.varungbu.varun

Hi Kamatchi,

 

If we are running a class from Visualforce page like clicking on button or links, it becomes easier to open a pop-up. But I have to a method and opening a pop-up. This method will run by web service.

 

Thanks,