Hi, don't want to discuss this endless.
The difference is in input type -> "submit" or "button", because the
script works in different ways in my browser. Otherwise I would not
discuss here....
But tell me just what alerts do you get in your browser if you check out
this html buttons.
I want just a feedback on this code to be sure that I don't see a fata
morgana. :-)
Bug 401 uses the button type "submit". How many alerts do you get on each
button?
<html>
<script>
function doSubmit() {
if(document.forms['unitItemViewList'].onsubmit)
{
if(
document.forms['unitItemViewList'].onsubmit() )
{
document.forms['unitItemViewList'].submit();
}
}
else
{
document.forms['unitItemViewList'].submit();
}
}
</script>
<body>
<form id="unitItemViewList" onsubmit="alert('form
onsubmit');return true;">
<input type="submit" value="submit"
onclick="doSubmit()" />
<input type="button" value="button test js
submit" onclick="doSubmit()">
</form>
</body>
</html>
On Thu, 29 Sep 2005 00:53:50 +0200, Jason THomas (JIRA)
<[email protected]> wrote:
[ http://issues.apache.org/jira/browse/MYFACES-401?page=comments#action_12330741
]
Jason THomas commented on MYFACES-401:
--------------------------------------
the following is correct:
if(document.forms['unitItemViewList'].onsubmit)
{
if( document.forms['unitItemViewList'].onsubmit() )
{
document.forms['unitItemViewList'].submit();
}
}
else
{
document.forms['unitItemViewList'].submit();
}
Calling .submit() does NOT call .onsubmit() and calling .onsubmit() does
NOT call .submit()
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: 1.1.1
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();
}