[ http://issues.apache.org/jira/browse/MYFACES-755?page=comments#action_12356259 ]
Martin Marinschek commented on MYFACES-755: ------------------------------------------- No, sorry - next version. > HTML links "onclick" - if "onsubmit" function exists, it's required to > explicitly return "true" (returning nothing considered as "false" and > clicking the link doesn't submit the form) > --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: MYFACES-755 > URL: http://issues.apache.org/jira/browse/MYFACES-755 > Project: MyFaces > Type: Bug > Components: Implementation > Versions: 1.1.1 > Environment: Windows XP, SP2 > Reporter: Evgeny Goldin > Assignee: Martin Marinschek > Fix For: Nightly > > Hello, > We're using MyFaces-1.1.1RC3. > The HTML link's "onclick" rendered by > org.apache.myfaces.renderkit.html.HtmlLinkRendererBase#renderJavaScriptAnchorStart > goes as following: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > if ( document.forms['id'].onsubmit ) > { > if( document.forms['id'].onsubmit()) document.forms['id'].submit(); > } > else > { > document.forms['id'].submit(); > } > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Which means "If form has 'onsubmit' handler and it's return value is 'true' - > submit the form". But it should be the other way around - "If form has > 'onsubmit' handler and it's return value is 'false' -don't submit the form". > The difference shows up if "onsubmit" handler returns nothing and return > value of calling"onsubmit() is "undefined" - in this case "if ( > form.onsubmit())" doesn't hold true and "form.submit()" isn't called. The > result - you have a form with "onsubmit" handler returning no value (it's > perfectly Ok) with non-working links, i.e clicking them causes no effect. > I believe the JavaScript code should be written in the following way: > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > if ( document.forms['id'].onsubmit ) > { > var result = document.forms['id'].onsubmit(); > if( isUndefined( result ) || result ) document.forms['id'].submit(); > } > else > { > document.forms['id'].submit(); > } > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > So far - we've just made our "onsubmit" handler to return "true" explicitly. > Thank you ! -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira