nini9140 / jzebra

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

jZebra applet caching and reusing cached label? #96

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
-What steps will reproduce the problem?
1. Use appendFile([file]) and print() methods to print a label
2. Change the contents of [file]
3. Repeat step 1

-What is the expected output? What do you see instead?

The new label should be printed, but instead the old label is printed. 

-What version of the product are you using? On what operating system?
1.4.5, Windows 7

-Please provide any additional information below.

I have verified that the contents of [file] have been changed, but jZebra 
prints the first file printed after the applet was loaded. 

Regardless of what I change the contents of [file] to, jZebra continues to 
print the first label it printed after the applet was loaded until the Java 
cache is cleared (it will print the new label after the Java security box pops 
up asking if I wish to run the applet, which I assume means that jZebra was 
un-cached).

This is happening on two separate computers.

Original issue reported on code.google.com by nathanho...@gmail.com on 13 Oct 2012 at 9:35

GoogleCodeExporter commented 9 years ago
Nathan,

This is particularly interesting because there are hundreds of people using 
this feature and this the first I've heard of it.

There is a feature called "printPersistent()" that caches the print contents, 
but I assume you're not using that.

One thing you can try doing is "applet.clear();" after you've printed.  This 
will force the print buffer to clear, although it is normally called 
automatically after all raw printing unless printPersistent() is called.

-Tres

Original comment by tres.fin...@gmail.com on 16 Oct 2012 at 3:51

GoogleCodeExporter commented 9 years ago
I should have followed up on this some time ago. Sorry, life has been hectic..

As I mentioned, after printing a label, the applet then continued to print the 
same label even though the file changed. 

I ended up doing the following:

1. Disabling the Java cache via these instructions: 
http://cyclic.ucsd.edu/javafiles.html
2. Adding <param name="cache_option" value="no"> after <param name="printer" 
value="zebra">
3. Adding applet.clear(); after printing

I tried a bunch of other things, too, but I think it was one of the above (or a 
combination, I haven't tried debugging further..) that fixed the issue. I 
haven't been having the problem any more.

Thanks,

Nate

Original comment by nathanho...@gmail.com on 12 Nov 2012 at 4:15

GoogleCodeExporter commented 9 years ago
I am also facing the same problem.

Original comment by chalam....@gmail.com on 11 Nov 2013 at 11:46

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
@Nathan,

If you are using identical URLs for file with different content this may 
happen.  A quick work-around to force a new version of the file is to provide a 
fake parameter to the end:

appendFile("/my/file.txt?fakeparameter");

This fake parameter can be in the form of a timestamp (i.e. new 
Date().getTime())

appendFile("/my/file.txt?" + new Date().getTime());

This forces the server to send a unique URL and should fix any caching issues 
you are encountering.

-Tres

Original comment by tres.fin...@gmail.com on 21 Nov 2013 at 3:45

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
sorry, I've tried the following manner: 
I ended up doing the following: 

1. Disabling the Java cache via these instructions: 
http://cyclic.ucsd.edu/javafiles.html 
2. Adding <param name="cache_option" value="no"> after <param name="printer" 
value="zebra"> 
3. Adding applet.clear (); after printing 
4. Adding new Date().getTime() after url file

but I still have the printout is double document, for example :
   - print document        : 001 up to 005
   - wrong printout result : 001 - 001 - 002 - 003 - 004  or 001 - 002 - 002 - 003 - 003 (irregular)
   - true printout result  : 001 - 002 - 003 - 004 - 005  
though when I try to check my document will print it is correct to first order 
the print results that I want. 
please help. 

Thanks,

Farhan Rifai

Original comment by mfarhanr...@gmail.com on 3 Apr 2014 at 3:19

GoogleCodeExporter commented 9 years ago
Please don't change the default cache options for Java that will not fix this 
issue. 

It has been over a year since you originally posted your bug report.  Which 
version of the software are you using?  What OS and what browser?

This appendFile() method has been reliable for many many people around the 
world so I'm not sure what you are describing is caused by the applet.

Please note, you MUST wait for the applet to finish appending (wait for 
qzDoneAppending() to be triggered) before sending a second document.  This will 
be fixed in 2.0.0 but for now you must wait or you will reach a race condition. 
Never provided a snippet of how you are using the applet, so it's all guess 
work from my perspective.

Original comment by tres.fin...@gmail.com on 3 Apr 2014 at 6:57

GoogleCodeExporter commented 9 years ago
I use Linux Ubuntu 12.4 64 bit for OS and browser use Chrome.

I've tried using appendFIle () on the applet, fermented appendFile () is not in 
the library program, and now I use append (myData) just to accommodate the data 
that I will make the results. 

allow you to show how to use the appendFile() ?

Thank's trees for the response.

Original comment by mfarhanr...@gmail.com on 4 Apr 2014 at 1:45

GoogleCodeExporter commented 9 years ago
appendFile() example is in sample.html please see 1.8.0.  

qz.appendFile("http://path_to_file/");

function qzDoneAppending() {
    qz.print();
}

Original comment by tres.fin...@gmail.com on 4 Apr 2014 at 3:51

GoogleCodeExporter commented 9 years ago
I use the print execution javascript. 
for example:

_printDirect: function(doc, user, count) {

        var applet = document.jzebra;
        applet.findPrinter();
        applet.append(String.fromCharCode(15)); //condensed font
        var strUrl = Rich.config.myProject + 'my_report_path/file.txt?bla=' + doc + '&userLogin=' + user;

        // PRINT DIRECT TO PRINTER
        Ext.Ajax.request({

            url: strUrl ,

            success: function (response) {

                var dataText = response.responseText;

                var title = "ABC";

                var no = "NO : ";
                var noDoc = doc;

                var title2 = String.fromCharCode(27) + String.fromCharCode(69) + String.fromCharCode(14) + title + String.fromCharCode(27) + String.fromCharCode(70);
                var no2 = String.fromCharCode(27) + String.fromCharCode(69) + no + String.fromCharCode(27) + String.fromCharCode(70);
                var noDoc2 = String.fromCharCode(27) + String.fromCharCode(69) + noDoc + String.fromCharCode(27) + String.fromCharCode(70);

                var firstWord = dataText.search(firstWord);
                var total = dataText.substr(firstWord, 54);
                var total2 = String.fromCharCode(27) + String.fromCharCode(69) + total + String.fromCharCode(27) + String.fromCharCode(70);

                var data = dataText.replace(title, title2, "g").replace(no, no2, "g").replace(noDoc, noDoc2, "g").replace(total, total2, "g");
                applet.append(data);
            }
        });

          applet.print();
          applet.clear();
}

so, when I use applet.appendFile(strUrl) the url I was not readable because it 
is not in the library appendFile() is. 

what the effect of jzebra version that I use today?

Original comment by mfarhanr...@gmail.com on 4 Apr 2014 at 7:39

GoogleCodeExporter commented 9 years ago
append() is synchronous so you do not need to wait, so that should work.  
appendFile() was based on your original bug report and appears it is not needed.

You haven't said which version you use, but the code you supplied should work 
just fine. What types of problems are you having?

Are you firing "print()" many times in a row?  You would need to wait until 
qzDoneAppending() is fired before printing again.

-Tres

Original comment by tres.fin...@gmail.com on 4 Apr 2014 at 3:38

GoogleCodeExporter commented 9 years ago
On this problem I've tried to check the output that I want to create an alert 
to display the url of documents to be printed,
alert that appears when it is in conformity with the output I want. 

for example: 
print the document 001 to 005, the result of alert has been ordered 001, 002, 
003, 004, 005 
but after the document has been print result is not like that, but there are 
still many documents are printed double. 

Please help,
Thanks for your response tress.

Original comment by mfarhanr...@gmail.com on 5 Apr 2014 at 1:21

GoogleCodeExporter commented 9 years ago
Please attach a sample file.  One post you state that you are using append() 
however the next post says you are using URL.

If you are doing appendFile() YOU MUST WAIT for it to finish before appending 
more.  This is a limitation of version 1.8.0.

-Tres

Original comment by tres.fin...@gmail.com on 5 Apr 2014 at 3:18

GoogleCodeExporter commented 9 years ago
Also, if you are using Ajax requests you must make sure you are synchronizing 
your data and not racing it to the applet.  Try to echo your commands to a DIV 
and see what order they appear in.

Original comment by tres.fin...@gmail.com on 5 Apr 2014 at 3:20

GoogleCodeExporter commented 9 years ago
We started seeing this issue when upgrading from jZebra to QZ Print 1.8.7

Original comment by mattias....@gmail.com on 15 Sep 2014 at 12:04

GoogleCodeExporter commented 9 years ago
@mattias,

This isn't reproducible on our end.  Contact us here and we should be able to 
work it out:

http://qzindustries.com/support

Original comment by tres.fin...@gmail.com on 15 Sep 2014 at 2:43

GoogleCodeExporter commented 9 years ago

Original comment by tres.fin...@gmail.com on 15 Sep 2014 at 2:45