Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Click af:commandButton from javascript

814457Jun 20 2011 — edited Jun 20 2011
Hey

I'm having the same issue as you. I want my session to be destroyed when a users closes the window.
As onUnload triggers every time you navigate away from the page I can't use it. Instead I'm using the following Js code:

<script type="text/javascript">
window.onbeforeunload=function(){
if (window.event.clientY &lt; 0 &amp;&amp; (window.event.clientX &gt; (document.documentElement.clientWidth - 5) || window.event.clientX &lt; 15) ) {
document.getElementById('hiddenButton').click();
}
}

</script>

my af:commandButton has the following structure :

<af:commandButton text="" id="hiddenButton"
onclick="if (confirm('#{res['sag.generales.cerrarSesion']}')) {window.document.all['logoutFrame'].src='../servlet/LogoutServlet';window.setTimeout('closeWindow()',100);}"/>
<af:regionDef var="attrs">

But is sadly not working. When I close the page nothing executes.

On the other hand if I use a regular button instead of an commandButton I'm able to click it via javascript
<input type="button" name="theSubmitButton" id="hiddenButton" value="Button" onclick="alert('The button was clicked.');"/>
i mean, in this case when i close the window i get the message "The button was clicked". But if I use the same code I have on the af:commandButton onclick for closing my session nothing happens.

I'm super new to adf and java so maybe I'm missing something obvious.

Thanks a lot for your hepl. I mean it :)

Edited by: loskiorama on Jun 20, 2011 8:54 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 18 2011
Added on Jun 20 2011
3 comments
1,519 views