Topic
  • 13 replies
  • Latest Post - ‏2012-12-12T21:24:19Z by bbski
bbski
bbski
26 Posts

Pinned topic Dojo Dialog Caching Images

‏2012-12-11T18:35:20Z |
Environment
Portal 6.1.5.1/WAS 7.0.0.23

We are having an issue where images are cached in our Dojo Dialog popups on IE9 only. All other browsers function correctly.

Here is how this is structured.
1) We generate links in a repeating grid using Dojo Form Dialog builder.
2) The Dojo dialog Action information is Link To An Action which points to an action list with parameters
3) The action list takes input parms and sets variables then calls an imported page
4) The imported page declares spans that are populated by HTML builders that set the span to image tags using define the 'src' using JSPSupport.getActionURL which makes a call into an LJO method. Here is a sample of this src set.


5) The LJO method makes a web service call to pull the image stream and returns it to the client using an output stream.

This works perfectly in all browers except for IE9. What happens is the first link is clicked and the dialog appears with the correct images. You can tell it's working as there is a delay between the time the dialog appears and the images appear.

When another link is clicked, the dialog appears immediately with the images from the previous link. Very much like they were cached. There is no delay.

I added a span to the imported page to display one of the parameters passed into the action list (specific to each link) to verify the page is being called and it is.

I've used Fiddler to watch the traffic and I see the first link click (that works), the ajax call to the method and the 2 JSPSupport.getActionURL that retrieve the images for a total of 3 calls.

The 2nd click, I just see the ajax call to the method but do not see the next 2 calls that retrieve the images.

I am completely stumped by this. Any help is greatly appreciated!
Updated on 2012-12-12T21:24:19Z at 2012-12-12T21:24:19Z by bbski
  • bbski
    bbski
    26 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-11T18:37:17Z  
    looks like my example code needed to be commented to appear correctly.

    <!--
    <img src='<%= JSPSupport.getActionURL(webAppAccess, webAppAccess.getBackchannelURLMapper(false), "checkImageUtility.streamFrontImage") %>'/>
    -->
  • bbski
    bbski
    26 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-11T18:50:34Z  
    As an update, I put logging at the end of the action list after all lines that set the vars + calls the page that contains the image links. I see the logging so it appears the AL is being called BUT the page is not retrieved or a cached version of the page WITH the resolved images is returned??? Definitely a caching issue.
  • mburati
    mburati
    2568 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-11T19:15:59Z  
    • bbski
    • ‏2012-12-11T18:50:34Z
    As an update, I put logging at the end of the action list after all lines that set the vars + calls the page that contains the image links. I see the logging so it appears the AL is being called BUT the page is not retrieved or a cached version of the page WITH the resolved images is returned??? Definitely a caching issue.
    If you post a sample (with no confidential info or intellectual property) showing what you're having trouble with, it might make it easier for someone to quickly spot what's wrong with it. Please also include what version of WEF (including fixpack level(s)) you've tried it with.

    You may also want to try IE Dev Tools to see if there are any JS errors occurring when the problem occurs and look at the response to that action list when the error occurs to see whether the results of the action are in those results or not).

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • bbski
    bbski
    26 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-11T19:22:23Z  
    • mburati
    • ‏2012-12-11T19:15:59Z
    If you post a sample (with no confidential info or intellectual property) showing what you're having trouble with, it might make it easier for someone to quickly spot what's wrong with it. Please also include what version of WEF (including fixpack level(s)) you've tried it with.

    You may also want to try IE Dev Tools to see if there are any JS errors occurring when the problem occurs and look at the response to that action list when the error occurs to see whether the results of the action are in those results or not).

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Hello Mike,
    Thanks for the reply.

    I have used IE dev tools and no errors whatsoever.

    I will try to put a sample together. Unfortunately, my experience with samples has been you never get to reproduce the original issue but will give it a shot.

    WebSphere Portlet Factory Designer
    Version: 7.0.0.2
    Build id: 201105180046
  • bbski
    bbski
    26 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T00:29:14Z  
    I figured out what the issue is. IE9 checks to see if the image "src" attribute is different between page GETS and if not, it displays the cached image.

    the trick is to "salt" the src url with something like a date string to make it different. I've tested this and it works as active model but not when I publish.

    My question now is, inside the HTML builder, how can I add a date string using javascript like something 'new Date().getTime()' to the JSPSupport.getActionURL string. I've tried something like the following but no luck.

    <!--
    <img src='<%= JSPSupport.getActionURL(webAppAccess, webAppAccess.getBackchannelURLMapper(false), "checkImageUtility.streamFrontImage") %>&time=javascript:new Date().getTime()'/>
    -->

    Is it possible to build the same URL using pure Java (LJO)?

    thx again
  • bbski
    bbski
    26 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T01:11:20Z  
    Sorry to keep updating my own ticket but hopefully this will help someone else out too.

    I am now able to generate the url within LJO using 'webAppAccess.getBackchannelActionURL' and it runs fine in active model but still fails when published to portal. This is because the URL is encrypted and the '&time=' query string paramter I added to the end is not encrypted with the entire URL as shown below:
    <!--
    <img id='ftImgUrl' src='/wps/myportal/!ut/p/c5/hY7NDoIwEISfhSfYpRbwyp9QAoglBsqFNKRBEn4MKs8vxIsXdOb4zewOVLB6lEvXymc3jbKHEiqzNvKjnToRxbOln5BxnyTU8AmitXJh1m5gh9SKEYOUu8ioQ0kYOATZ4U-72P59JzLuIYsSzjy86pibH_7r_sZxRzZCGk6DAgHC2t0RGFDM6jG95kbBpZHNTcVqUX0mWwU5CDeD-1Bily2Jb2vaG2KUdwY!/&time=1355274096915' />
    -->

    I have no idea how get around this. Hopefully, someone has some ideas to try.

    thx!
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T01:36:49Z  
    • bbski
    • ‏2012-12-12T01:11:20Z
    Sorry to keep updating my own ticket but hopefully this will help someone else out too.

    I am now able to generate the url within LJO using 'webAppAccess.getBackchannelActionURL' and it runs fine in active model but still fails when published to portal. This is because the URL is encrypted and the '&time=' query string paramter I added to the end is not encrypted with the entire URL as shown below:
    <!--
    <img id='ftImgUrl' src='/wps/myportal/!ut/p/c5/hY7NDoIwEISfhSfYpRbwyp9QAoglBsqFNKRBEn4MKs8vxIsXdOb4zewOVLB6lEvXymc3jbKHEiqzNvKjnToRxbOln5BxnyTU8AmitXJh1m5gh9SKEYOUu8ioQ0kYOATZ4U-72P59JzLuIYsSzjy86pibH_7r_sZxRzZCGk6DAgHC2t0RGFDM6jG95kbBpZHNTcVqUX0mWwU5CDeD-1Bily2Jb2vaG2KUdwY!/&time=1355274096915' />
    -->

    I have no idea how get around this. Hopefully, someone has some ideas to try.

    thx!
    Does checkImageUtility.streamFrontImage() return an image url? If so, just have it append &blah where blah is a random number. You don't even have to make it a query string param in the form of time=blah. blah can just be the long returned from System.currentTimeMillis()

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • bbski
    bbski
    26 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T01:48:21Z  
    Does checkImageUtility.streamFrontImage() return an image url? If so, just have it append &blah where blah is a random number. You don't even have to make it a query string param in the form of time=blah. blah can just be the long returned from System.currentTimeMillis()

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Sam,
    checkImageUtility.streamFrontImage() actually returns the image stream and is called when the browser does a GET on the URL created by the following LJO method:

    public String getFrontImageURL(WebAppAccess webAppAccess) {
    Date d = new Date();
    String url = webAppAccess.getBackchannelActionURL("checkImageUtility.streamFrontImage", false) + "&time=" + String.valueOf(d.getTime());
    String tag = String.format("", url);
    return tag;
    }
    I think the issue is the &time=xxxxx (not encoded) is appended to the result of the webAppAccess.getBackchannelActionURL (Base64 encoded).

    If I could:
    1) decode string generated by webAppAccess.getBackchannelActionURL
    2) append the time
    3) encode everything into single URL string
    4) return

    It works as Active Model because URL's are not encoded.
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T01:58:45Z  
    • bbski
    • ‏2012-12-12T01:48:21Z
    Sam,
    checkImageUtility.streamFrontImage() actually returns the image stream and is called when the browser does a GET on the URL created by the following LJO method:

    public String getFrontImageURL(WebAppAccess webAppAccess) {
    Date d = new Date();
    String url = webAppAccess.getBackchannelActionURL("checkImageUtility.streamFrontImage", false) + "&time=" + String.valueOf(d.getTime());
    String tag = String.format("", url);
    return tag;
    }
    I think the issue is the &time=xxxxx (not encoded) is appended to the result of the webAppAccess.getBackchannelActionURL (Base64 encoded).

    If I could:
    1) decode string generated by webAppAccess.getBackchannelActionURL
    2) append the time
    3) encode everything into single URL string
    4) return

    It works as Active Model because URL's are not encoded.
    What does Firebug show as the url added to the img tag on the page? And if you cut the link from firebug and paste it into the same authenticated session, what happens?

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • mburati
    mburati
    2568 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T04:10:11Z  
    • bbski
    • ‏2012-12-12T01:11:20Z
    Sorry to keep updating my own ticket but hopefully this will help someone else out too.

    I am now able to generate the url within LJO using 'webAppAccess.getBackchannelActionURL' and it runs fine in active model but still fails when published to portal. This is because the URL is encrypted and the '&time=' query string paramter I added to the end is not encrypted with the entire URL as shown below:
    <!--
    <img id='ftImgUrl' src='/wps/myportal/!ut/p/c5/hY7NDoIwEISfhSfYpRbwyp9QAoglBsqFNKRBEn4MKs8vxIsXdOb4zewOVLB6lEvXymc3jbKHEiqzNvKjnToRxbOln5BxnyTU8AmitXJh1m5gh9SKEYOUu8ioQ0kYOATZ4U-72P59JzLuIYsSzjy86pibH_7r_sZxRzZCGk6DAgHC2t0RGFDM6jG95kbBpZHNTcVqUX0mWwU5CDeD-1Bily2Jb2vaG2KUdwY!/&time=1355274096915' />
    -->

    I have no idea how get around this. Hopefully, someone has some ideas to try.

    thx!
    If you get a reference to the URLMapper first and then use that to generate the URL (eg, getBackchannelURLMapper(...) instead of taking the shortcut getBackChannelActionURL(...)method right from webAppAccess to the URL), then there's an additional method ( addQueryParameter(...) ) on it to add a parameter to a URL. I don't recall if a unique query param value will result in a unique encoded portlet Action URL, so you'd have to try that. If you tack it on manually, then maybe check to see if the existing one has ?= already and if not add ?time= otherwise add &time= ?

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • bbski
    bbski
    26 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T20:19:25Z  
    • mburati
    • ‏2012-12-12T04:10:11Z
    If you get a reference to the URLMapper first and then use that to generate the URL (eg, getBackchannelURLMapper(...) instead of taking the shortcut getBackChannelActionURL(...)method right from webAppAccess to the URL), then there's an additional method ( addQueryParameter(...) ) on it to add a parameter to a URL. I don't recall if a unique query param value will result in a unique encoded portlet Action URL, so you'd have to try that. If you tack it on manually, then maybe check to see if the existing one has ?= already and if not add ?time= otherwise add &time= ?

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    ok, took your advice and again, it works in Active Model but not published. I've attached my code + logging (specific info is masked out). I generated the url using getBackchannelURLMapper's getURL method passing in the model and method name.

    My first test was to NOT include the timestamp query string parm just to make verify the URL generated from getBackchannelURLMapper worked like the url returned by webAppAccess.getBackchannelActionURL and in Active Model, they are identical. In portal, they are different and the url from getBackchannelURLMapper throws an exception inside my method.

    I did call the addQueryParameter just to verify what it looked like in Active Model and it looks great. if only I can get this to cooperate in portal land.
  • mburati
    mburati
    2568 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T20:41:15Z  
    • bbski
    • ‏2012-12-12T20:19:25Z
    ok, took your advice and again, it works in Active Model but not published. I've attached my code + logging (specific info is masked out). I generated the url using getBackchannelURLMapper's getURL method passing in the model and method name.

    My first test was to NOT include the timestamp query string parm just to make verify the URL generated from getBackchannelURLMapper worked like the url returned by webAppAccess.getBackchannelActionURL and in Active Model, they are identical. In portal, they are different and the url from getBackchannelURLMapper throws an exception inside my method.

    I did call the addQueryParameter just to verify what it looked like in Active Model and it looks great. if only I can get this to cooperate in portal land.
    Without more info on what the exception is (and maybe a stack trace) it's hard to guess what's going on, but in theory those two methods of generating the URL should be equivalent (note, portal URLs contain state info and possibly a unique id to prevent form double-submission, so they may differ even if you generate the same URL multiple times).

    The original method you called (getBackchannelActionURL(...) does pretty much what your more granular code does with the separate API calls, so I would expect those two to behave the same:

    The API call getBackchannelActionURL(String action, boolean renderOuterPage)

    just calls this: return getBackchannelURLMapper(renderOuterPage).getURL(getModelName(), action);

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • bbski
    bbski
    26 Posts

    Re: Dojo Dialog Caching Images

    ‏2012-12-12T21:24:19Z  
    • mburati
    • ‏2012-12-12T20:41:15Z
    Without more info on what the exception is (and maybe a stack trace) it's hard to guess what's going on, but in theory those two methods of generating the URL should be equivalent (note, portal URLs contain state info and possibly a unique id to prevent form double-submission, so they may differ even if you generate the same URL multiple times).

    The original method you called (getBackchannelActionURL(...) does pretty much what your more granular code does with the separate API calls, so I would expect those two to behave the same:

    The API call getBackchannelActionURL(String action, boolean renderOuterPage)

    just calls this: return getBackchannelURLMapper(renderOuterPage).getURL(getModelName(), action);

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Hi Mike,

    I owe you!! The trick was calling WebAppAccess.getModelName() in the getURL call instead of using a hard-coded string containing the model name.

    Also, adding the query string timestamp parameter has solved the issue of cached images for IE9.

    So, for anyone with this same issue, here is the code that generates a "unique" url that can be used in the "src" attribute of an img tag. Be sure to change the "checkImageUtility.streamFrontImage" to your own LJO method name.

    <!--
    String timestamp = String.valueOf((new Date()).getTime());
    URLMapper mpr = webAppAccess.getBackchannelURLMapper(false);
    String actionUrl = mpr.getURL(webAppAccess.getModelName(), "checkImageUtility.streamFrontImage");
    actionUrl = mpr.addQueryParameter(actionUrl, "time", timestamp);
    -->

    Thanks again for all your support!

    Happy holidays and take care.