Transfer and trigger javascript code by ajax call with jsf -


i have jsf-code tag re-rendered ajax call. contains

<h:outputscript>alert("gotcha")</h:outputscript> 

but executed on first load, not on ajax induced partial render.

this minimal example, i'm trying trigger server-generated javascript right after ajax-call has returned, like

<h:outputscript>#{scriptbean.getscript()}</h:outputscript> 

i've seen calling .trigger("click") in javascript code returned ajax call, asynchronize ajax calls , javascript code, how run call javascript code jquery element loads page ajax? , running javascript code called ajax, neither questions nor answers address question, least not without additional hint or explanation.

and because want keep things small , simple, , because avoid above jsf:core (mostly), i'd prefer solutions avoid using yafl (== yet fancy library).

edit: comment @balusc post more context:

<composite:implementation>     <h:form id="${cc.attrs.imgid}" styleclass="small" onchange="alert('gotcha0');">         <f:event type="postaddtoview" listener="#{mbean.register}" />         <f:event type="prerenderview" listener="#{mbean.init}" />         <f:attribute name="flav" value="#{cc.attrs.flav}" />         <h:graphicimage width="${cc.attrs.width}" id="${cc.attrs.imgid}"             onclick="if (event.istrusted) this.nextsibling.value=mods(event);"             onmouseover="aa=this.id" alt="not found"             onchange="alert('gotcha1');"             value="images/img?#{cc.attrs.flav}=#{mbean.getnextcount()}&amp;imgid=#{cc.attrs.imgid}">             <f:ajax event="click" execute="@form"                 onevent="function(data) { if (data.status === 'success') {                  console.log('hiho'+data.responsecode+'\n\n'+ data.responsetext+'\n\n'+data.responsexml);                 me=window.document.getelementbyid('#{cc.clientid}:#{cc.attrs.imgid}:#{cc.attrs.imgid}');                 me.nextsibling.nextsibling.value=0;                 me.nextsibling.value=0;                 me.myfunc=function(event)                  {                  console.log('keycode='+event.keycode+' mods='+mods(event)+'/'+this.nextsibling.id);                     this.nextsibling.value=mods(event);                     this.nextsibling.nextsibling.value=string.fromcharcode(event.keycode);                     this.click();                  }; }; }"                 listener="#{mbean.handleevent}" render="@this">             </f:ajax>         </h:graphicimage>         <h:inputhidden id="m" value="#{mbean.keyx}" />         <h:inputhidden id="k" value="#{mbean.key}" />     </h:form>     <h:outputscript>alert("gotcha2")</h:outputscript>     <h:outputscript>var i=0;window.document.getelementbyid('#{cc.clientid}:#{cc.attrs.imgid}:#{cc.attrs.imgid}').myfunc=function(event)      {      aa='#{cc.clientid}:#{cc.attrs.imgid}:#{cc.attrs.imgid}';      this.nextsibling.value=mods(event);      this.nextsibling.nextsibling.value=string.fromcharcode(event.keycode);      this.click();      };      </h:outputscript> </composite:implementation> 

"gotcha2" shows @ load time, once each instance of composite, not when component re-rendered via ajax calls.

"gotcha0" , "gotcha1" ignored.

the "hiho" shows every ajax-call on component, function fire when component rendered, subtle difference, because might manipulate render-list on server side, like

  private void addtorendermap(string obj) {     facescontext context = facescontext.getcurrentinstance();     collection<string> renderids = context.getpartialviewcontext().getrenderids();     renderids.add(obj);   } 

or remove calling component list. (for example, keypress "i", want show image information in other component , avoid unnecessary re-sending of image data.)

edit2: see onchange more onvaluechange fields take input, it's not big surprise part of code ignored.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -