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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745623601a4636669.html
评论列表(0条)