I have a simple form and a pretty simple bean that listens to an ajax event. Here is some of the code:
<script type="text/javascript">
function myfunction() {
alert('error');
}
</script>
<h:mandButton id="someid" value="somevalue" >
<f:ajax event="click" execute="someids" listener="#{MyBean.fireEvent}" onerror="myfunction()" />
</h:mandButton>
I am using eclipse in debug to see when MyBean.fireEvent
is getting called and as far as I can tell it is getting called after onerror="myfunction()"
is executed. What could be the reason for that?
I am using mojarra 2.0 with Resin.
Thanks.
I have a simple form and a pretty simple bean that listens to an ajax event. Here is some of the code:
<script type="text/javascript">
function myfunction() {
alert('error');
}
</script>
<h:mandButton id="someid" value="somevalue" >
<f:ajax event="click" execute="someids" listener="#{MyBean.fireEvent}" onerror="myfunction()" />
</h:mandButton>
I am using eclipse in debug to see when MyBean.fireEvent
is getting called and as far as I can tell it is getting called after onerror="myfunction()"
is executed. What could be the reason for that?
I am using mojarra 2.0 with Resin.
Thanks.
Share Improve this question edited Nov 28, 2012 at 18:51 BalusC 1.1m376 gold badges3.7k silver badges3.6k bronze badges asked Jul 5, 2012 at 19:13 casolorzcasolorz 9,66422 gold badges107 silver badges219 bronze badges 1-
Figured out how to get it to work. Above the
myfunction()
definition I addedjsf.ajax.addOnError(myfunction);
and removed theonerror="myfunction()"
attribute from the ajax tag. I am still curious as to why the onerror attribute didn't work though. – casolorz Commented Jul 5, 2012 at 19:30
2 Answers
Reset to default 5looks like a formatting problem, maybe try:
<script type="text/javascript">
function myfunction(error) {
alert(error.description);
}
</script>
<h:mandButton id="someid" value="somevalue" >
<f:ajax event="click"
execute="someids"
listener="#{MyBean.fireEvent}"
onerror="myfunction" />
</h:mandButton>
The onerror
attribute must point to the function name itself, not to the return value of the function.
So, if you replace
onerror="myfunction()"
by
onerror="myfunction"
then it should work as expected.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745141113a4613435.html
评论列表(0条)