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
Beth G.Beth G. 

Apex and Visualforce Page- pop-up window notice to user-sample code

I am trying to create a Vforce page that will pop up a notice to the user, Is it possible to get some sample code for that?

The idea would be to popup a message to the user after they complete some require fields on a custom object.

Subramani_SFDCSubramani_SFDC

 

 


After making all the changes and clicking the save button you add

 

<apex:CommandButton action="{!Save}"  onClick="popupWindow();" value="Save" />

 

Write the Script in the visual force

 

<apex:page>

<apex:form>

<script>

popup(){

Window.open('/VFPage Name');

}

ok(){

Window.close();

}

</script>

 

<apex:CommandButton action="{!Save}"  onClick="popupWindow();" value="Save" />

<apex:CommandButton action="{!ok}"  onClick="popupWindow();" value="ok" /> // This and the script for ok to be on the popup page.

</apex:form>

</apex:page> 

 

If this gives helps you make this as a solution.

Yoganand GadekarYoganand Gadekar

see if this helps you out,

 

http://cloudforce4u.blogspot.in/2013/07/javascript-validation-in-visualforce.html

mark thisa s answer and hit kudos if it helped you.

crop1645crop1645

Here's another approach - -using only VF and VF controller, no Javascript

 

http://www.tehnrd.com/visualforce-pop-up/

Beth G.Beth G.

I am trying to create a popup window to appear to the user in the UI. So I created a a VF page for the popup window. Also I created another VF-page associate to the the custom object that I want the popup window to appear.  However when I try to call the other VF-page it is not appearing ( see the popupcomannd VF-page).  Why?

 

Also, I need the popup window to appear when the user enters 'Feature Request Name" (required field) on the custom object. What would the javascript be?

 

 

VF-page (labeled: popupcommand)

<apex:page standardcontroller="Feature_Request_Form__c" >
<apex:form >
<script>
popup(){
Window.open('/message');
}
ok(){
Window.close();
}
</script>
</apex:form>
</apex:page>

 

VF-page (labeled message) popup window code:

 

<apex:page controller="popup">
    <apex:form >
        <apex:commandButton value="Show Pop up" action="{!showPopup}" rerender="popup"/>
        <apex:outputPanel id="popup">
            <apex:outputPanel styleClass="customPopup" layout="block" rendered="{!displayPopUp}">
           To complete the request, click on <b>Submit for Approval</b> button located on the <b>Approval History</b> section of this page. <br/><br/><br/>
                <apex:commandButton value="Hide Pop up" action="{!closePopup}" rerender="popup"/>
            </apex:outputPanel>
        </apex:outputPanel>
 
    </apex:form>
 
    <style type="text/css">
       .customPopup{
            background-color: white;
            border-style: solid;
            border-width: 1px;
            left: 50%;
            padding:10px;
            position: absolute;
            z-index: 9999;
            /* These are the 3 css properties you will need to tweak so the pop 
            up displays in the center of the screen. First set the width. Then set 
            margin-left to negative half of what the width is. You can also add 
            the height property for a fixed size pop up.*/
            width: 500px;
            margin-left: -250px;
            top:100px;
        }
    </style>
</apex:page>

the controller  is

 

public class popup {
 
    public boolean displayPopup {get; set;}
 
    public void closePopup() {
        displayPopup = false;
    }
 
    public void showPopup() {
        displayPopup = true;
    }
}

crop1645crop1645

Beth -- It looks like you are using tehNrd's solution

 

His solution, if you examine it carefully, uses a single VF page /apex/popup that contains a button 'show popup' that manipulates controller variables to make the outputpanel as popup visible/invisible.

 

Look at his demo here: http://tehnrd-developer-edition.na7.force.com/popup

Carlos NaranjoCarlos Naranjo
I have a question in regards to the popup on Beth post. I really hope you guys can help me with it. I want to use the popup from the demo but with a vairation.
I have a pagereference save() method that will save the page on this standard action in my visualforce page. Is possible to have my commandbutton triggering the "save" action and on he sametime to launch this popup window?

The save action is very simple: <apex:commandButton action="{!save}" value="Save Descriptions" id="saveDescription" />

And the code for this method is this:

public PageReference save(){
  
      this.stanController.save(); 
      return page;
       
  }


I think that I can't add two actions to a commandbutton, but probably can modify the apex code?
Any help on this would be much appreciated.
Thanks.
Carlos NaranjoCarlos Naranjo
Please ignore my question from above, I already solved it. Actually was very simple. All I did was to add both methods from the popup class to my class and add the displayPopUp boolean on my save() method. Now if a user clicks on the commandbutton in my visualforce page, the popup will appear in the middle of the page. I need to work out some statement condition to make this a bit more intuitive, but this is already a step further.
Thanks for the code!