Struts 2 stream result download when no data is available - struts2

I am trying to dynamically generate a file for user to download depending on the records in database. I have successfully done this by using stream result.
The problem is, when there is no data available to download, I want to show a dialog in the browser to tell the user 'No data available'.
Can anybody tell me how should this be done? When there is no data, the input stream to download is null and there will be exception..
Thanks

You would use a different result and handle notification on the client side. There are any number off ways to simulate a dialog box via HTML and JavaScript, or you could use plain HTML.

Related

Delphi - read content that is loaded dynamically

I want to read the content (html) of a certain URL. I send a GET command, receive the html and I do what I want to do with it, no problem here.
The problem happens when a site loads more info into itself when you scroll down (like Facebook does), so the content I receive is the default one without the parts that are yet to be loaded. Any idea what can be done to retrieve the next parts automatically so I can read more and more of the content of such site?
I saw something about phantomJS but I'm developing a desktop application (using Delphi) so I can't use it. Thanks.

JSF print screen like capture

I am generating some linecharts via JSF (Primefaces).
So charts are accessible and generated nicely via accessing in any browser.
However i need to send those charts via email to certain persons cause they do not want to click on a link so this should be automated.
Is there a way to generate an image out of what the JSF is rendering ?
Thanks
Charts are canvas based and can be exported as static images with client side api.
Take a look here:
http://www.primefaces.org/showcase/ui/chartExport.jsf
Primefaces use Javascript Libraries to render the charts. You would have to process the browser output before sending the email.
(Also, lazy managers)
You would have to dig into the Java Image API (not JSF) in order to plot the graph (from the raw data) into an image if you want the JVM to send the email.
If you want to just automate the process in your machine to send the emails (so you can send the emails in one click instead of doing it all manually, be mindful of this caveat:
You would have to generate a custom page with print CSS and your email layout, then use a browser plugin that sends the email on a click.

webapi mvc4 fileupload with progressbar using ProgressMessageHandler Class

http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2 shows how to upload files. However I would like to have someone show me the code example where I can display the progress of the file upload using ProgressMessageHandler class. So far I was able to find examples of the class being used in WPF or console application, but I would like to use it either on the MVC controller method or the WebAPI method directly and show the upload progress to JQuery UI progress bar. Can someone post the sample code of how it can be done?
So you want to display the send progress on the client, by tracking the receive progress on the server? Keep in mind that the ProgressMessageHandler class is server-side code.
In order to do what you're proposing, every time the server receives a packet, it would need to send back to the client the details of the progress. But in order for a web browser to receive any data, it must first request it. So the browser would have to upload the file, and simultaneously be asking the server for progress updates?
I think you've got this all backwards. If you're wanting to display file upload progress in a web browser you need to look at browser technologies. Like the HTML5 upload (there's plenty of examples out there of using HTML5 to track file upload progress). Or one of the pre-HTML5 options that got a lot of mileage was Shockwave Flash plugins. GMail does, or at least did use a Shockwave Flash plugin for progress reporting on attachment uploads for example.

Storing data in Iphone

I have a web site. This is a drupal site using PostgreSQL database.In this web site we can get direction data from one city to another by going to direction tab and giving start and end location.go to this URL and check that. http://www.zoomsrilanka.com/pathfinder .
direction data is loaded to dashboard. I want export that direction data to a iPhone so that this data can be used another application in the iPhone. If I tell in another words I want to send that data and need to store in a iPhone so that it can be used for another task. I want to know that how to store data in iPhone?
If you have control for the website you mentioned, You can create one webservice which will give you the required data in XML format by accepting parameters from iPhone.
i.e. you can call webservice from iPhone passing parameters and your webservice will provide response to that request in the form of XML and on receiving XML you can parse that and use according to your requirement.
It's not possible to share data between different IPhone applications. Each application has it's own "storage".
You can create API if you have access of server which you mentioned, API should give XML/JSON in response, so iPhone can take this response and parse accordingly, and store structure in sqlite local database.

how to build web scanner? scan webpage if content has been change and save it

i need to build a web scanner.
this web application must scan any webpage and save result if some data has been changed.
it should to search for key words and seek if their values has been modifyed/changed.
i will create this application with asp.net mvc.
what should i use to scan some webpage? if i will insert in my page any url of page which i will to scan, what should happens? are they some robots which looking for it if some content changes?
please help me to understand what i need to build such thing.
You could load the page's markup, use it to generate a checksum and then store this away ready to compare with the next day's page.

Resources