cancel
Showing results for 
Search instead for 
Did you mean: 

Button executing CloseWindow Java Script and raising event on server

Former Member
0 Kudos

Hi All.

Somebody can help me with this:

<b>What i'm needing:</b> an 'END' button on a BSP, when the user click on this button just show an aswer box asking if the user wants to close the windows, in case to click yes close the current window and execute a business logic in the controller.

<b>What i have:</b> a button with the event onClientClick invoking a Java Script function which is showing the answer box and the event onClick which raise the event on the server side. The thing is if the user click on yes then i'm closing the current window and the server event never is triggered. This is not working !!!

Any ideas ? some sample code ?

Thanks in advance.

Armando.

Accepted Solutions (0)

Answers (1)

Answers (1)

thomasalexander_ritter
Active Contributor
0 Kudos

Hi,

it seems that you need a modal dialog for your "Yes/No" dialog. When you search google for "javascript modal dialog" you will get lots of examples how to solve your problem. I found these two which are not bad <a href="http://www.eggheadcafe.com/articles/javascript_modal_dialog.asp">first one</a> <a href="http://www.getyourwebsitehere.com/jswb/modwin/modalwinparent.html">second one</a>.

regards

Thomas

Former Member
0 Kudos

No thomas.

The java Script: var myJavaScript = answer('myAsnwer'); is doing this functionality. What i want to do is a button, when the user press this button call the javascript myJavaScript and deppending if the answer is "yes" call in the controller of the view a method XXX with ABAP logic and next close the window.

maybe i was not explicit in the last post.

Armando.

Former Member
0 Kudos

Hi Armando,

The 'Yes' on the <i>Confirm dialog box</i> (Client Side Scripting) has to tell the application (Server side scripting) to call your METHOD XXX. This is done by passing querystring <i>exit=X</i> to the URL.

1. Comment onClick event of the button.

2. Modify the code the JS function of your End button as follows

func_end()

{

//if no

// your original code

// if yes

document.location.href = document.location.href + '?exit=X';

}

3. Add following code to DO_REQUEST

IF REQUEST->GET_FORM_FIELD( NAME = 'exit' ) ne space.

*your method will be called only when there is an exit=x in the url

call method XXX.

*set a page attrib as follows

l_exit = 'X'.

ENDIF.

4. Add following code to your layout

<%if l_exit = 'X'.%>

<script>

window.close();

</script>

<%endif.%>

Regards,

Alwyn