Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Reload image from Img widget

    I have a Img object in my layout and need it to reload the image url it is associated with.
    The URL I passed with setSrc() is a servlet streaming an image file that can change and I need the Img object to reload the URL some times.
    As the docs say the image object does not do anything if I pass to setSrc the same URL it is already assigned to, but also calling redraw() didn't get it to reload the image. I even tried assigning it another URL pointing to another image and afterwards reset the src to the servlet URL, but this also showes the "old" image that was previously returned by my servlet.

    How can I get the Img object to reload the image from its src-URL?

    Here is some code:
    In my constructor I create the Img object
    logo = new Img("/myImageServlet", 200, 200);
    logo.setImageType(ImageStyle.STRETCH);
    logo.setBorder("1px solid gray");
    myLayout.addMember(logo);

    After some user interaction in another function I want the logo object to reload the image from "/myImageServlet", so I already tried all functions I could thought of:
    logo.setSrc("/images/shim.png");
    logo.redraw();
    logo.resetSrc();
    logo.draw();
    logo.setSrc("/myImageServlet");

    But after this still the Img shows the image returned by myImageServlet when it got loaded by creation of the Img in the constructor even though myImageServlet would return another image at that moment.

    To be sure the problem is not due to some cashing, I also added the no-cache header in the myImageServlet:
    response.setHeader("Pragma", "No-cache");
    response.setDateHeader("Expires", 0);
    response.setHeader("Cache-Control", "no-cache");


    Thanks for any hint
    Last edited by mswiege; 26 May 2010, 12:26.
Working...
X