I'm creating an image from an external source (a qrcode on a java ee server). When my Angular2 app updates the data for the image, everything gets updated on the server but the resulting image is not refreshed in the angular app. I'm currently doing a zone.run but it doesn't seem to refresh the image, Everything is fine if the entire page gets refreshed (eg. if I place a location.reload). Anybody no how to properly refresh an image from an external source?
template has this:
<img [src]=url />
component has this:
this.zone.run(()=>{
this.url = QRURL + this.selectedProduct.id;
});
QRURL is a constant that contains the server's url that executes the generation of the image.
The quotes didn't fix it, but Maxime's 2nd comment did. My constant alread y had a query string, so I just added the date stuff as another parameter on it, and that did the trick and I was able to strip off the zone.run. The final variable looked like this:
this.url = QRURL + this.selectedProduct.id + '&date=' + new Date().getTime();
Thanks!
Related
I'm using an AjaxLink and in it's onClick() method i'm doing the following stuff:
start download (getRequestCycle().scheduleRequestHandlerAfterCurrent( new RedirectRequestHandler("http://" + url "));)
display feedback message (download started...)
update ListView (add text to it)
add the container (div) which contains the feedbackpanel and the ListView to the target: (target.add(...);)
So, the only thing what happens at first is the download dialog is shown and i can save it to my disk. But no feedback message is shown and the content stays the same (should be updated).
But if i press F5, the page gets reloaded and the feedback messages are shown and the content is updated. But i want to show it directly.
On the other side: if i remove the download call (getRequestCycle().scheduleRequestHandlerAfterCurrent( new RedirectRequestHandler("http://" + url "));) from the onClick mehtod, it works.
So, the download is not triggered BUT the feedback messages are shown and the content is updated.
So, how can i handle that? The redirect / download causes the problem it seems.
I'm using wicket 6.
Edit:
The url is calculated with RandomStringUtils for example...
getRequestCycle().scheduleRequestHandlerAfterCurrent(new RedirectRequestHandler("http://" + url + "/test/" + randomString + "/download"));
So i need java / wicket to do the stuff.
You cannot serve the file contents and simultaneously send an Ajax response:
https://cwiki.apache.org/confluence/display/WICKET/AJAX+update+and+file+download+in+one+blow
I have an aspx page with a calendar control on it. When I try to print this page to PDF none of my images or calendar gridlines are showing up. However when I go directly to the page everything is fine. Also I had this working on our dev server but once it was moved to a new server all the images and the gridlines stopped appearing. I have tried a few suggestions on here such as using full file paths for images with no success. Has anyone run into a similar issue? I put my code for creating the PDF below though I don't think that's the issue since I had it working on a different server before.
string url = HttpContext.Current.Request.Url.AbsoluteUri;
int lastDash = url.LastIndexOf('/');
url = url.Remove(lastDash + 1);
url += "print.aspx";
theDoc.AddImageUrl(url, true, width , true);
theDoc.Flatten();
theDoc.Clear();
I added the line of code below and the images and lines are now appearing. Though this answered my question the printed pages is very screwed now and needs to be fixed.
Doc theDoc = new Doc();
theDoc.HtmlOptions.Engine = EngineType.Gecko;
I would like to display a graphic image in a jsf web application from a html file that's changing for each run.
The problem is that the displayed image was always the same.
I tried to solve this by generating a random number at the end of the image name.
public String getImageId () {
String imageId = "";
int nb = (int)Math.random();
imageId = "?id="+Integer.toString(nb);
return imageId;
}
Then, I call it in my jsf page
<h:graphicImage value="/images/Report.html_files/img_0_0_0#{MyBean.imageId}" cacheable="false" />
But nothing change.
Do you Have any idea about this ?
Thanks
For my application, I
created a Java Servlet that returns a different image
each time, with HTTP header Cache-Control
set to prevent caching and I use the servlet URL in my JSF tag.
I do not think you can dynamically change the image with a URL
to a static file, like in your example.
Another palliative solution, is force refresh in your browser using the keys CTRL + SHIFT + R.
I'm having some trouble with the firefox and ie cache, on my website the user can make a query with a form, and this query returns a picture, but depending on which radio button is selected, it'll return a different picture, and it works just like that on chrome, but in IE and firefox, the same image is always returned, it only changes when i reopen the browser, can you guys give me some light on how to make this work?
Thanks to everyone, i solved my problem by putting and unique url each time i made the ajax call.
<?php $date = date("H:i:s");
echo ''; echo '<img src="web/WEB-INF/classes/lineChart.php?id='.$date.'" alt="">' ?>
Not sure the language you are using to code with, but regardless I am sure the strategy will work across the board. I pass an arbitrary value in the query string, something like a GUID or the datetime stamp. This will force a fresh load as the URL will be unique.
I use ASP.NET MVC which I then set a optional parameter in my route, which the controller method ignores. I then set my URL via JavaScript:
d = new Date();
$('.thumbnail').attr('src', $('.thumbnail').attr('src') + d.getTime());
The solution I needed was unique, so this is probably not similar to what you are trying to resolve. However, it should get the point across.
do private browsing in Firefox and see if image is changes successfully and problem is with cache memory or with the code
Given a unique can be the solution, but you have to watch the length in the string can keep growing, now, you can use this option at the begining of your code
$.ajaxSetup({ cache: false });
this will disable caching.
i am using .ashx to retrive image and i place the the image inside the ajax update panel it retrive the image when a new image is added to the form but when we change the image it is not updating the image it dont even call the .ashx file but when i refresh the browser it works properly
Sounds like a caching issue. Try adding some of the lines found here to your ashx file and it should hopefully force the browser to rerequest the image. (I know that the link is for ASP rather than ASP.NET, but things like Response.Expires = -1 should work)
Alternatively, can you change the path to the image in the updatepanel? If you just add a random parameter on to the end of it the browser will treat it as a fresh request (we use the current date/time as a parameter when we're doing this. The parameter is ignored by ASP.NET unless you explicitly reference it)
Do something like this:
var sPath = "../../handlers/ProcessSignature.ashx?type=View&UserID=" + userID + "&d=" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
That puts a 4 character alpha numeric string at the end of your query string. It's not needed, but it will force browsers to pick up the latest version of that image because the URL is different.
I tried the above and some browsers ignore the headers. I threw all of those in and Chrome/FireFox 3 didn't try to update.
IE7 worked sometimes
IE6 just twiddled it's thumbs and asked why it was still in existence.
Changing the path above will fix it in all browsers.