+ Start a Discussion
PrattyPratty 

Stop displaying Popup On every page refresh

Hello All,

 

I have a page which opens a popup after every refresh i.e. at the time of loading,

at the time of displaying errors.

 

I want that it shows popup only for the first time when it loads and not for second time when it shows error message.

 

Here's short code,

 

<body class="Secondary" onload="clickme();" >

 

function clickme()
{

$( "#dialog-form" ).dialog( "open" );

}


***************************************************************************************************************************

 

public class demo
{

public PageReference gotonext()
{

if(all is ok)
{
return Page.nextpage;
}
else
{

System.debug('Error has been occured');
return null;
}

}

}

 

can anybody help me to solve above issue.

 

Thanks in advance.

 

Regards,

Pratty

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You should be able to control the rendering via a controller property.  Something like:

 

public class demo
{
   public Boolean showPopup {get; set;}

   public demo()
   {
      showPopup=true;
   }

   public PageReference gotonext()
   {
      if(all is ok)
      {
         return Page.nextpage;
      }
      else
      {
         System.debug('Error has been occured');
         showPopup=false;
         return null;
      }
   }
}
 

 

and the page:

 

<body class="Secondary" <apex:outputText value='onload="clickme();"' rendered="{!showPopup}"/> >

 

 

All Answers

bob_buzzardbob_buzzard

You should be able to control the rendering via a controller property.  Something like:

 

public class demo
{
   public Boolean showPopup {get; set;}

   public demo()
   {
      showPopup=true;
   }

   public PageReference gotonext()
   {
      if(all is ok)
      {
         return Page.nextpage;
      }
      else
      {
         System.debug('Error has been occured');
         showPopup=false;
         return null;
      }
   }
}
 

 

and the page:

 

<body class="Secondary" <apex:outputText value='onload="clickme();"' rendered="{!showPopup}"/> >

 

 

This was selected as the best answer
PrattyPratty

Hey Bob,

 

It works fine, thank you very much.

 

Regards,

 

pratty