-
1. Re: oncomplete does not get fired after actionListener finished processing
ppitonak May 25, 2011 2:52 PM (in response to ginc)Hi Gregor,
I've tried both jsFunction and commandButton and oncomplete works fine in Chrome and IE9. Could you please provide more information about your environment?
Regards,
Palo
-
2. Re: oncomplete does not get fired after actionListener finished processing
ginc May 25, 2011 5:54 PM (in response to ppitonak)I have tried it now in Firefox 3.6.17, IE9 - neither of them work.
I am using richfaces 4.0.0.Final and jsf 2.1.1
When executing the following code, the alert of oncomplete does not occur. ActionListener works fine.
This:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j">
<h:head>
<title>test</title>
</h:head>
<h:body>
<f:view>
<h:form id="main_form" acceptCharset="UTF-8">
<a4j:commandButton value="test" actionListener="#{ChatBean.syncInput}" oncomplete="alert('hello')" />
</h:form>
</f:view>
</h:body>
</html>
Produce the following html code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
<link type="text/css" rel="stylesheet" href="/rfRes/skinning.ecss.jsf?db=eAHL6rC8BQAEkAIG"/>
<script type="text/javascript" src="/javax.faces.resource/jsf.js.jsf?ln=javax.faces&stage=Development"></script>
<script type="text/javascript" src="/javax.faces.resource/jquery.js.jsf"></script>
<script type="text/javascript" src="/javax.faces.resource/richfaces.js.jsf"></script>
<script type="text/javascript" src="/javax.faces.resource/richfaces-queue.js.jsf"></script>
</head>
<body>
<form id="main_form" name="main_form" method="post" action="/test2.jsf" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="main_form" value="main_form"/>
<input id="main_form:j_idt6" name="main_form:j_idt6"
onclick="RichFaces.ajax("main_form:j_idt6",event,{"incId":"1"} );return false;"
value="test" type="submit"/><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState"
value="-608878335606438827:-3715234858006091902" autocomplete="off"/>
</form>
</body>
</html>
The funny thing is, oncomplete is NOT there! if I change it to any other event, like onclick or onmousedown, it is there and therefore works fine.
Looks like a bug to me, still..
Any thoughts about that?
-
3. Re: oncomplete does not get fired after actionListener finished processing
snaker May 26, 2011 6:47 AM (in response to ginc)try this:
<h:form>
<a4j:outputPanel ajaxRendered="true">
<a4j:commandLink.....>
</a4j:outputPanel>
</h:form>
-
4. Re: oncomplete does not get fired after actionListener finished processing
ginc May 26, 2011 8:04 AM (in response to snaker)This also does not work. Neither with commandLink nor with commandButton.
@Kike I am wondering why this would solve the problem anyway. The problem is not that it is there but does not get called. It ist not there at all and therefore does not get called. So the question is - why is the oncomplete not rendered.
-
5. Re: oncomplete does not get fired after actionListener finished processing
ppitonak May 26, 2011 8:12 AM (in response to ginc)Hi Gregor,
I tried your sample in Glassfish 3.1, JBoss 6.0.0.Final and Tomcat 6.0.32 with Mojarra 2.0.4 and 2.1.1-b04 and I still cannot reproduce the bug. I see alert each time.
Regarding the rendered markup...it's usual that oncomplete is not rendered on the page. Actually it cannot be rendered because it is not a HTML attribute (unlike onclick). Otherwise the markup wouldn't be valid. When I watch Ajax request, I see the following response for your sample:
<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="javax.faces.ViewState"><![CDATA[1548791213828025428:-1613907399947497364]]></update><extension id="org.richfaces.extension"><complete>alert('hello');</complete></extension></changes></partial-response>
As you can see, there is alert('hello') in "complete" part of the response.
Regards,
Palo
-
6. Re: oncomplete does not get fired after actionListener finished processing
ginc May 26, 2011 8:22 AM (in response to ppitonak)Hi Palo,
I certainly do understand that oncomplete is not rendered like the others, since it is not a html standard element. I probably articulate myself not clear enough.
Anyway, since it seems just to be an issue at my side, how can I figure out what the problem is? I mean it is a very simple example, so i don't know what to change anymore in order to make it work.
Any suggestions?
Gregor
-
7. Re: oncomplete does not get fired after actionListener finished processing
ppitonak May 26, 2011 8:56 AM (in response to ginc)Could you prepare a simple project? I would try it.
-
8. Re: oncomplete does not get fired after actionListener finished processing
snaker May 26, 2011 11:04 AM (in response to ppitonak)because render all elements inside outputpanel when you pulse the button and it would render oncomplete and show the alert
-
9. Re: oncomplete does not get fired after actionListener finished processing
snaker May 26, 2011 11:10 AM (in response to snaker)one question
you have this:
<a4j:jsFunction name="syncInput"......>
and
<a4j:commandButton actionListener="#{ChatBean.syncInput}"......>
What momment are you calling jsFunction??? you try call jsFunction with actionListener="#{ChatBean.syncInput}"???
-
10. Re: oncomplete does not get fired after actionListener finished processing
ginc May 26, 2011 11:25 AM (in response to ginc)I have found the piece of code which was responsible for this issue.
Back in the days, when using jsf 1.2, I was using a phase listener from balusC (http://balusc.blogspot.com/2007/03/post-redirect-get-pattern.html), for redirect purposes. It seemed to work fine with the new version too.. Well, it does not. Using this phaselistener prevents the oncomplete attribute from beeing executed. So I removed it. Now it works fine.
@Palo thanks for making me prepare a simple project.. :-)
@Kike thanks for your inputs, for sake of completeness - i was not about to call jsFunction with the actionListener. I just needed to ways to access the actionListener. one from a button, one from an key event ('enter' within a inputbox)
Problem solved.. Now back to work.
Gregor