samuraiza / jzebra

Automatically exported from code.google.com/p/jzebra
0 stars 0 forks source link

QZ print with a ASP.Net UpdatePanel #248

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.have a button print within the update panel
2.in the click event handler from code behind register a call to deployQZ():
 ScriptManager.RegisterStartupScript(this, this.GetType(), "deployQZ", "deployQZ();", true);

3.the page get blank and only the applet code in the body of the page:
<applet id="qz" code="qz.PrintApplet.class" archive="dist/qz-print.jar" 
width="1" height="1">
<param name="jnlp_href" value="dist/qz-print_jnlp.jnlp"><param 
name="cache_option" value="plugin"><param name="disable_logging" 
value="false"><param name="initial_focus" value="false"><param 
name="codebase_lookup" value="false">
</applet>

What is the expected output? What do you see instead?
to load Java and allow and print, instead it's showing a blank page.
if I remove the updatepanel everything is working fine

What version of the product are you using? On what operating system?
qz-print 1.8.7 on Windows 7

Please provide any additional information below.

Original issue reported on code.google.com by baha...@gmail.com on 25 Jun 2015 at 1:01

GoogleCodeExporter commented 9 years ago
I'd recommend either hard-coding your applet tags, or using some tricks to 
prevent your page from getting wiped out.

Here's how we are doing it in 1.9

https://github.com/qzind/qz-print/blob/1.9/sample.html#L172

Original comment by tres.fin...@gmail.com on 25 Jun 2015 at 1:14

GoogleCodeExporter commented 9 years ago
Hi,
Thanks for your prompt response.
Can you please explain how hard-coding the applet tag will help. Like I said 
the applet is still there, and that's all I can see in the page, the rest of 
the HTML is gone.

Original comment by baha...@gmail.com on 30 Jun 2015 at 5:31

GoogleCodeExporter commented 9 years ago
> Can you please explain how hard-coding the applet tag will help. 

deployJava uses the JavaScript function "document.write" which wipes out the 
page contents.  Per Oracle, it is only intended to be at the top of a page.  
This means if it is called after page load it will wipe our your entire page.   
More here:

http://stackoverflow.com/questions/13517790/using-deployjava-runapplet-to-target
-specific-element

-Tres

Original comment by tres.fin...@gmail.com on 30 Jun 2015 at 5:34

GoogleCodeExporter commented 9 years ago
Thanks Tres for the link. Much appreciated.

The following code for the link worked for me:

function docWriteWrapper(func) {
    var writeTo = document.createElement('del'),
        oldwrite = document.write,
        content = '';
    writeTo.id = "me";
    document.write = function(text) {
        content += text;
    }
    func();
    writeTo.innerHTML += content;
    document.write = oldwrite;
    document.body.appendChild(writeTo);
}
An then:

docWriteWrapper(function () {
    deployJava.runApplet(attributes, parameters, "1.6");
});

Original comment by baha...@gmail.com on 2 Jul 2015 at 5:27