admin管理员组文章数量:1025465
I get result to JavaScript from native NPAPI/XPCOM/ActiveX. Previously user activate native GUI by:
<h:mandLink styleClass="send-doc-link" value="#{msg.send}" onclick="javascript:signDocument('data');return true;" action="#{internalPayment.sendDocument}"/>
and JavaScript function 'signDocument' finish execution after user quit from add-on GUI.
I switch native code to asynhronouse model. So JS func 'signDocument' return execution imediatly and result must be fetched lately.
I write JS code, like this:
function signDocument(dataTagID, tagID4Event) { var npapi = document.getElementById("npapi"); npapi.Sign(langId, content, desc, ts, sign); mylog("OK"); var scheduler = setInterval( function() { mylog("FAIL"); if (npapi.AddonGetState() != "finished") return; clearInterval(scheduler); out_sign = npapi.SignValue(); fireHTMLEvent(tagID4Event, 'click'); }, 1000); } }
which try get result in 1 sec interval and emulate link pressing by firing 'click' event. All work fine on test static HTML test.
I rewrite .jsf file to:
<h:mandLink styleClass="send-doc-link" value="#{msg.send}" onclick="javascript:signDocument('data', 'signDocumentCallbackID');return true;"/> <t:mandLink styleClass="hidden" id="signDocumentCallbackID" forceId="true" onclick="return true;" action="#{internalPayment.sendDocument}"/>
I expect that scheduler fetch result and fire event. But scheduler do not invoked because after user click to first link (visible) JS call native code which create separate thread for GUI and execution returned to JS. Next page reloaded and seems all JS object die as page die (I check this by 'mylog' func).
Really first h:mandLink
tag converted to:
<a href="#" onclick="var cf = function(){javascript:signDocument('data', 'signDocumentCallbackID');return true;};var oamSF = function(){return oamSubmitForm('j_id_jsp_179411707_1','j_id_jsp_179411707_1:j_id_jsp_179411707_5');};return (cf()==false)? false : oamSF();" class="send-doc-link">...
So to my JS code added oamSubmitForm
which seems reload my page and delete sheduler.
How stop include special code to onclick=""
?
I get result to JavaScript from native NPAPI/XPCOM/ActiveX. Previously user activate native GUI by:
<h:mandLink styleClass="send-doc-link" value="#{msg.send}" onclick="javascript:signDocument('data');return true;" action="#{internalPayment.sendDocument}"/>
and JavaScript function 'signDocument' finish execution after user quit from add-on GUI.
I switch native code to asynhronouse model. So JS func 'signDocument' return execution imediatly and result must be fetched lately.
I write JS code, like this:
function signDocument(dataTagID, tagID4Event) { var npapi = document.getElementById("npapi"); npapi.Sign(langId, content, desc, ts, sign); mylog("OK"); var scheduler = setInterval( function() { mylog("FAIL"); if (npapi.AddonGetState() != "finished") return; clearInterval(scheduler); out_sign = npapi.SignValue(); fireHTMLEvent(tagID4Event, 'click'); }, 1000); } }
which try get result in 1 sec interval and emulate link pressing by firing 'click' event. All work fine on test static HTML test.
I rewrite .jsf file to:
<h:mandLink styleClass="send-doc-link" value="#{msg.send}" onclick="javascript:signDocument('data', 'signDocumentCallbackID');return true;"/> <t:mandLink styleClass="hidden" id="signDocumentCallbackID" forceId="true" onclick="return true;" action="#{internalPayment.sendDocument}"/>
I expect that scheduler fetch result and fire event. But scheduler do not invoked because after user click to first link (visible) JS call native code which create separate thread for GUI and execution returned to JS. Next page reloaded and seems all JS object die as page die (I check this by 'mylog' func).
Really first h:mandLink
tag converted to:
<a href="#" onclick="var cf = function(){javascript:signDocument('data', 'signDocumentCallbackID');return true;};var oamSF = function(){return oamSubmitForm('j_id_jsp_179411707_1','j_id_jsp_179411707_1:j_id_jsp_179411707_5');};return (cf()==false)? false : oamSF();" class="send-doc-link">...
So to my JS code added oamSubmitForm
which seems reload my page and delete sheduler.
How stop include special code to onclick=""
?
- h:mandLink will add form submit logic when render on onClick, you should consider simple anchor tag if you want no extra javascript. – Asad Rasheed Commented Jun 21, 2011 at 11:09
1 Answer
Reset to default 3If you don't need to invoke a synchronous backing bean action with a link, then just replace <h:mandLink>
by <h:outputLink>
or just <a>
.
<h:outputLink styleClass="send-doc-link" onclick="signDocument('data', 'signDocumentCallbackID')">
<h:outputText value="#{msg.send}" />
</h:outputLink>
or
<a href="#" styleClass="send-doc-link" onclick="signDocument('data', 'signDocumentCallbackID')">
<h:outputText value="#{msg.send}" />
</a>
Note that the javascript:
pseudoprotocol and the return true;
are totally superfluous. Both are already the default. You would probably also use return false;
instead so that the link's default action (going to top of page) will be blocked.
I get result to JavaScript from native NPAPI/XPCOM/ActiveX. Previously user activate native GUI by:
<h:mandLink styleClass="send-doc-link" value="#{msg.send}" onclick="javascript:signDocument('data');return true;" action="#{internalPayment.sendDocument}"/>
and JavaScript function 'signDocument' finish execution after user quit from add-on GUI.
I switch native code to asynhronouse model. So JS func 'signDocument' return execution imediatly and result must be fetched lately.
I write JS code, like this:
function signDocument(dataTagID, tagID4Event) { var npapi = document.getElementById("npapi"); npapi.Sign(langId, content, desc, ts, sign); mylog("OK"); var scheduler = setInterval( function() { mylog("FAIL"); if (npapi.AddonGetState() != "finished") return; clearInterval(scheduler); out_sign = npapi.SignValue(); fireHTMLEvent(tagID4Event, 'click'); }, 1000); } }
which try get result in 1 sec interval and emulate link pressing by firing 'click' event. All work fine on test static HTML test.
I rewrite .jsf file to:
<h:mandLink styleClass="send-doc-link" value="#{msg.send}" onclick="javascript:signDocument('data', 'signDocumentCallbackID');return true;"/> <t:mandLink styleClass="hidden" id="signDocumentCallbackID" forceId="true" onclick="return true;" action="#{internalPayment.sendDocument}"/>
I expect that scheduler fetch result and fire event. But scheduler do not invoked because after user click to first link (visible) JS call native code which create separate thread for GUI and execution returned to JS. Next page reloaded and seems all JS object die as page die (I check this by 'mylog' func).
Really first h:mandLink
tag converted to:
<a href="#" onclick="var cf = function(){javascript:signDocument('data', 'signDocumentCallbackID');return true;};var oamSF = function(){return oamSubmitForm('j_id_jsp_179411707_1','j_id_jsp_179411707_1:j_id_jsp_179411707_5');};return (cf()==false)? false : oamSF();" class="send-doc-link">...
So to my JS code added oamSubmitForm
which seems reload my page and delete sheduler.
How stop include special code to onclick=""
?
I get result to JavaScript from native NPAPI/XPCOM/ActiveX. Previously user activate native GUI by:
<h:mandLink styleClass="send-doc-link" value="#{msg.send}" onclick="javascript:signDocument('data');return true;" action="#{internalPayment.sendDocument}"/>
and JavaScript function 'signDocument' finish execution after user quit from add-on GUI.
I switch native code to asynhronouse model. So JS func 'signDocument' return execution imediatly and result must be fetched lately.
I write JS code, like this:
function signDocument(dataTagID, tagID4Event) { var npapi = document.getElementById("npapi"); npapi.Sign(langId, content, desc, ts, sign); mylog("OK"); var scheduler = setInterval( function() { mylog("FAIL"); if (npapi.AddonGetState() != "finished") return; clearInterval(scheduler); out_sign = npapi.SignValue(); fireHTMLEvent(tagID4Event, 'click'); }, 1000); } }
which try get result in 1 sec interval and emulate link pressing by firing 'click' event. All work fine on test static HTML test.
I rewrite .jsf file to:
<h:mandLink styleClass="send-doc-link" value="#{msg.send}" onclick="javascript:signDocument('data', 'signDocumentCallbackID');return true;"/> <t:mandLink styleClass="hidden" id="signDocumentCallbackID" forceId="true" onclick="return true;" action="#{internalPayment.sendDocument}"/>
I expect that scheduler fetch result and fire event. But scheduler do not invoked because after user click to first link (visible) JS call native code which create separate thread for GUI and execution returned to JS. Next page reloaded and seems all JS object die as page die (I check this by 'mylog' func).
Really first h:mandLink
tag converted to:
<a href="#" onclick="var cf = function(){javascript:signDocument('data', 'signDocumentCallbackID');return true;};var oamSF = function(){return oamSubmitForm('j_id_jsp_179411707_1','j_id_jsp_179411707_1:j_id_jsp_179411707_5');};return (cf()==false)? false : oamSF();" class="send-doc-link">...
So to my JS code added oamSubmitForm
which seems reload my page and delete sheduler.
How stop include special code to onclick=""
?
- h:mandLink will add form submit logic when render on onClick, you should consider simple anchor tag if you want no extra javascript. – Asad Rasheed Commented Jun 21, 2011 at 11:09
1 Answer
Reset to default 3If you don't need to invoke a synchronous backing bean action with a link, then just replace <h:mandLink>
by <h:outputLink>
or just <a>
.
<h:outputLink styleClass="send-doc-link" onclick="signDocument('data', 'signDocumentCallbackID')">
<h:outputText value="#{msg.send}" />
</h:outputLink>
or
<a href="#" styleClass="send-doc-link" onclick="signDocument('data', 'signDocumentCallbackID')">
<h:outputText value="#{msg.send}" />
</a>
Note that the javascript:
pseudoprotocol and the return true;
are totally superfluous. Both are already the default. You would probably also use return false;
instead so that the link's default action (going to top of page) will be blocked.
本文标签: javascriptHow to stop JSF reload page quotonclickquotStack Overflow
版权声明:本文标题:javascript - How to stop JSF reload page "onclick"? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745623599a2159724.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论