commandbutton onclick return value of javascript function does not work
[Logo]
ICEfaces Forums
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
commandbutton onclick return value of javascript function does not work  XML
Forum Index -> General Help
Author Message
wmueller

Joined: 29/05/2008 00:00:00
Messages: 37
Offline


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.
wmueller

Joined: 29/05/2008 00:00:00
Messages: 37
Offline


No one? Perhaps this is a bug in Icefaces. Someone else know this bug?
wmueller

Joined: 29/05/2008 00:00:00
Messages: 37
Offline


I have looked at the generate html. There the code for the attribute looks likte this:

Code:
 showDialog('Löschen');iceSubmit(form,this,event);return false;
 


It is easly to see that the iceSubmit(form,this,event); is never called when I call my funcion because it has a return statment.

I have tried to add the code iceSubmit(form,this,event); into my function but I get an error that form is not found.

Has someone else an Idea?
wmueller

Joined: 29/05/2008 00:00:00
Messages: 37
Offline


I found this in the forum:

Code:
 iceSubmitPartial(document.getElementById("myForm"),document.getElementById("myForm:myButton"),MouseEvent.CLICK); 
 


But I get the js error:


MouseEvent ist undefiniert
 


Has someone a Idea? I cant believe that nobody has any ideas.
mark.collette


Joined: 07/02/2005 00:00:00
Messages: 1223
Offline


Have you tried using:
if(!showDialog('Are you sure?')) {return false;}
[Email]
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team