+ Start a Discussion
csbaacsbaa 

dialog box from vf page

Hello Helpers

 

I would like  to  display a popup  dialog  box  from inside the Visual force  page  After  the action  method  is finished at the controller side. the diualog  Box  should  display a simple message  something like  "operation succesfull"

 

 

 

<apex:commandButton  action="{!FunctionFromapexcontroller}"   "/>

 

I know  how  to  diplay  message boxes  using Javascipt  onclick()  evewnt handler but these messages fire before the 

action  method  starts

 

 

I need a message  after  the method  in controller finish

 

any suggestions are welcommed

 

Thanks in advancs

csaba

 

 

 

Best Answer chosen by csbaa
izayizay

Ok, In that case what may work is to use the oncomplete event to call a javascript function inside an apex:outputpanel which is re-rendered when the command button is clicked. Use a property alertMessage{get; private set} in your controller which holds the message. Set the message in your FunctionFromController Ex.

 

<apex:outputPanel id="ScriptPanel">

    <script type="text/javascript">

        function alertStatus(){

            alert({!alertMessage});

        }

</script>

 

<apex:commandButton  action="{!FunctionFromapexcontroller}"   oncomplete="javascript&colon;alertStatus();" reRender="ScriptPanel"/>

All Answers

izayizay

Hi,

 

You can add an alert('Message'); to the oncomplete event. Ex.

 

<apex:commandButton  action="{!FunctionFromapexcontroller}"  oncomplete="alert('operation succesfull')" />

 

Hope this helps!

csbaacsbaa
Thanks for your fast reply

My problem is that the popup dialog box should display a message returned by the method from the apex controller. Or should display a string member property of the controller class set by the apex method

Sent from my iPad
izayizay

Ok, In that case what may work is to use the oncomplete event to call a javascript function inside an apex:outputpanel which is re-rendered when the command button is clicked. Use a property alertMessage{get; private set} in your controller which holds the message. Set the message in your FunctionFromController Ex.

 

<apex:outputPanel id="ScriptPanel">

    <script type="text/javascript">

        function alertStatus(){

            alert({!alertMessage});

        }

</script>

 

<apex:commandButton  action="{!FunctionFromapexcontroller}"   oncomplete="javascript&colon;alertStatus();" reRender="ScriptPanel"/>

This was selected as the best answer