Hello,
I have a short js function in a js file.
Code:
function showDialog(message)
{
if (!confirm(message))
{
return false;
}
return true;
}
The js file is included in the main template file (I use facelets)
Code:
<head>
<script type="text/javascript" src="scripts/general.js"></script>
</head>
In a different file which is include in the template via ui:composition and ui:define. Here I have a command button with the onclick attribute that calls the js function
Code:
<ice:commandButton id="button2" type="button" image="/images/icons/delete.gif" actionListener="#{Listener.select}" action="#{ActionBean.delete}" onclick="return showDialog('Are you sure?');">
No the funny part. When I use this function the dialog shows up but i can press any button i want nothing is happend. Which means the action is not executed when I press OK.
When I add the js code direcktly in the onclick attribute (without calling a function) it works fine.
Now my question: Why?
I do not want to have any "free" js code in my pages. The code must come from js files so that it is easier to use checkstyle. We want to avoid that any developer add his customer javascript to the pages.
I hope ICEfaces has an answer for this.