No problem :-) I could even explain better and easier... but it was late, too ;-)
Thanks! Martin Marinschek wrote:
Now I get you! sorry for my misunderstanding, it was 4 in the morning and I've had a long day ;) gonna change that... regards, Martin On 9/21/05, Paul Klaer <[EMAIL PROTECTED]> wrote:Hi Martin, yes, I agree with you that the first if clause is only a check. But this is not the problem. The second if clause is it. If there exists a function it is then executing for the first time and if this function returns to true it executes the onsubmit for the second time... Please change in your form onsubmit function to return true. And you get the "'executing onsubmit'" message twice. if(document.forms['form1'].onsubmit) { alert('checked onsubmit is existing. everything ok here.'); if(alert('now execute onsubmit first time, if I result to true I will execute it by submitting in the statement again!');document.forms['form1'].onsubmit()) { alert('Now the first onsubmit returned true and I submit the form and execute onsubmit again!'); document.forms['form1'].submit();} } else { document.forms['form1'].submit(); } return false; } Martin Marinschek (JIRA) wrote:[ http://issues.apache.org/jira/browse/MYFACES-401?page=all ] Martin Marinschek closed MYFACES-401: ------------------------------------- Fix Version: Nightly Build Resolution: Fixed Don't think so: the first call to onsubmit is no call, but just a check if the function is existing. try out the following test file and see what happens: <html> <head> </head> <body> <form id="form1" target="#" onsubmit="alert('executing onsubmit');return false;"> <input type="submit" onclick="if(document.forms['form1'].onsubmit){alert('checked onsubmit is existing'); if(document.forms['form1'].onsubmit()){document.forms['form1'].submit();}}else{document.forms['form1'].submit();}return false;}"/> </form> </body> </html>CommandLink tag override onsubmit function of Form -------------------------------------------------- Key: MYFACES-401 URL: http://issues.apache.org/jira/browse/MYFACES-401 Project: MyFaces Type: Bug Components: Implementation Versions: 1.1.0 Environment: Tomcat 5.0.28 Reporter: Zhong Li Assignee: Martin Marinschek Priority: Critical Fix For: Nightly Build Attachments: bugfix_myfaces-401.txt I have java script onsubmit in <h:form>, when I use commandLink tag, even onsubmit return false, the form still submitted. I checked javasctipt, If I am right, the bug should be here, JSF generate Javascript for each commandLink like, clear_unitItemViewList(); document.forms['unitItemViewList'].elements['autoScroll'].value=getScrolling(); document.forms['unitItemViewList'].elements['unitItemViewList:_link_hidden_'].value='unitItemViewList:_id49_0:_id72'; if(document.forms['unitItemViewList'].onsubmit){document.forms['unitItemViewList'].onsubmit();} document.forms['unitItemViewList'].submit(); return false; ---------------------- so problem it will be caused by if(document.forms['unitItemViewList'].onsubmit){document.forms['unitItemViewList'].onsubmit();} document.forms['unitItemViewList'].submit(); //the form submitted!!!!!! it should be if(document.forms['unitItemViewList'].onsubmit) { if( document.forms['unitItemViewList'].onsubmit() ) { document.forms['unitItemViewList'].submit(); } } else { document.forms['unitItemViewList'].submit(); }
