Hello Efrat,
Sorry before this, I couldn't understand the exact situation of how the user can submit the page without clicking the command button.
Ok I had a similar situation. In my case, if the user is doing an activity type and if he is in the middle of it and clicks on any other menu item or navigation tree, then we are showing an alert to warn user with message, "Are you sure you want to cancel this activity".
This is done in the backing bean.
In your case, set a boolean variable in the backing bean,and check if the user is in the current page,(or any other condition) and set boolean to true, else false and save the state of it in the page. So now whenever any other item in the menu is clicked, the action attribute of that menu item calls a method in the backing bean. That method should check for the boolean value and return the javaScript alert, Check for this condition in all the other items action methods, which the user can click on that page, except the commandButton.
For Eg., in the
jsp, each menu item will be,
In the bean,
This method will return the javascript alert without submitting the current page.
Hope this helps,
-Rajani.