Problem displaying deployJava button on ajax rerender

I'm having trouble displaying the deploy-java button on ajax rerender

<h:form id="deployJavaForm" rendered="#{myBean.shouldRender}"> <h:outputScript library="js" name="http://java.com/js/deployJava.js" target="head" /> <script type="text/javascript"> deployJava.createWebStartLaunchButton('blah.jnlp', '1.7.0'); </script> </h:form> 

when

 myBean.shouldRender == true 

and the form is updated, the only thing that is displayed (on the white page) is the deployJava button, and the request remains hanging. if shouldRender is true upon initial request, the page and button are displayed correctly. Im using in case he can help.

I want the button to display correctly, regardless of whether its part is ajax rerender or the full initial request.

Update: I did my homework and created a minimal example that still reproduces the problem. It seems I am still having the same problems, regardless of whether the script declaration is in the head or in the body (I have an deployJava.js instance in / js resources)

 <?xml version="1.0" encoding="UTF-8"?> <!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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> <h:head> <!-- <script type="text/javascript" src="http://java.com/js/deployJava.js" />--> </h:head> <h:body> <h:outputScript library="js" name="deployJava.js" target="head" /> <h:form id="djForm"> <script type="text/javascript"> deployJava.createWebStartLaunchButton( 'test.jnlp', '1.7.0'); </script> <p:commandButton value="update" update="djForm" /> </h:form> </h:body> </html> 

edit: (special materials) below the test give the same problem as before.

 <h:outputScript> deployJava.createWebStartLaunchButton( 'test.jnlp', '1.7.0'); </h:outputScript> 

edit: image added The problem looks like this

after clicking the refresh button, only the deployJava button is displayed and the page loads

edit (daniel): both on success and oncomplete give the same behavior: (

 <h:form id="djForm"> <h:outputScript> function abcefg() { deployJava.createWebStartLaunchButton('test.jnlp', '1.7.0'); } </h:outputScript> <p:commandButton value="update" update="djForm" onsuccess="abcefg()" /> </h:form> 
+1
source share
2 answers

As an alternative to using the js and css visibility described in my comment, you can write your own custom button component. Using Firebug, you can figure out what markup is created using the deployJava.createWebStartLaunchButton script and add it yourself. So your component could be:

 <!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:composite="http://java.sun.com/jsf/composite"> <head> <title>deployJava Button component</title> </head> <body> <composite:interface> <composite:attribute name="version" required="true" type="java.lang.String" /> <composite:attribute name="url" required="true" type="java.lang.String" /> </composite:interface> <composite:implementation> <a onmouseover="window.status=''; return true;" href="javascript:if (!deployJava.isWebStartInstalled(&quot;#{cc.attrs.version}&quot;)) {if (deployJava.installLatestJRE()) {if (deployJava.launch(&quot;#{cc.attrs.url}&quot;)) {}}} else {if (deployJava.launch(&quot;#{cc.attrs.url}&quot;)) {}}"><img border="0" src="//java.com/js/webstart.png" /></a> </composite:implementation> </body> </html> 

so your page will be:

 <?xml version="1.0" encoding="UTF-8"?> <!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:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:comps="http://java.sun.com/jsf/composite/comps" xmlns:p="http://primefaces.org/ui"> <h:head> <!-- <script type="text/javascript" src="http://java.com/js/deployJava.js" />--> </h:head> <h:body> <h:outputScript library="js" name="deployJava.js" target="head" /> <h:form id="djForm"> <comps:deployJavaButton version="1.7.0" url="test.jnlp" rendered="#{myBean.shouldRender}" /> <p:commandButton value="update" update="djForm" /> </h:form> </h:body> </html> 

The basic idea is to avoid creating a script button twice or more.

+2
source

Can be used h: panelGroup instead of h: form will help. Something like that:

 <h:form id="djForm"> <h:panelGroup rendered="#{myBean.shouldRender}"> <script type="text/javascript"> deployJava.createWebStartLaunchButton( 'test.jnlp', '1.7.0'); </script> </h:panelGroup> <p:commandButton value="update" update="djForm" /> </h:form> 
+1
source

All Articles