I have a requirement to update my view while my GWT application doing GWT RPC. Here is my case, I have to send some data to my GWT servlet, then in my servlet, I feed it to a server side component (optaplanner solver), and it will run for some time. This component have a event handler for every un-final result released. Now what I want is to get those un-final result and populate it in my view until the final result was released from the optaplanner solver component. These requirement very similar to upload file and track the progress. Please kindly give me your suggestions how to achieve this.
Thanks & Regards.
You have two options:
Start a timer in your GWT code which will periodically ask the server "Do you have something for me?" The server may respond with null or with the intermediate results that you can show to your user.
Use a server-push technology.
The timer option is much simpler - it requires only a few lines of code and no external libraries. It is also a standard solution when the timing of an event is not critical (unlike games and some other applications).
Related
Basically, I need to update below screen shot details for every application generated or every build occurs in Installr app. I thoroughly checked API there is no method to help the above scenario.
I need to auto Provisioning the IOS application for each Build.
Now I am trying to accomplish that above task using Java, Jsoup web Scraping Technic . Please Let us know if the task is not possible to using above techs stack also suggest me any other JS to full fill the requirement.
I can see two options for you:
Option 1: Stay with your current techs stack...
Fire up the network tab in the developer toolbar of your favorite browser.
Play the scenario manually in your browser and carefully study the HTTP exchanges between your browser and the server.
Once you have understand the exchanges made, reproduce them with Jsoup in your Java code.
Option 2: Change your techs stack
I suggest you to try one the tools below:
Selenium
ui4j
Both handle Javascript and will facilitate the automation of your scenario.
They will automatically determine the appropriate exchanges to do.
We are developing a Wicket Application where users can log in and perform searches on a Lucene index. They can also modify their own, small index.
We have great test coverage for single-user scenarios. However, as the application is intended to be run on a server and have multiple, concurrent users, I would like to be able to set-up a test that covers this scenario (e.g. 1 application, 10 concurrent users).
I have some experience using jmeter, but I would prefer a WicketTester-style approach if possible.
Does anyone have expercience setting up such a test? Or good pointers?
We also use Wicket but concurrent users is not my main focus (no end-users). Sometimes I need to check cookie-behaviour, session-management etc. and then I use SAHI which also exists as open source IMO and as a demo. We use the Pro version also in other projects. From my perspective easy to learn and to handle.
_navigateTo("http://myapp/login.html");
// login as first user
...
// launch a new browser instance
var $instanceId = _launchNewBrowser("http://myapp/login.html");
_wait(5000);
// wait and select the new browser instance using the instanceId
_selectBrowser($instanceId);
// log in as second user
// send a chat message to first user
...
// Select the base window
_selectBrowser();
// view chat window and verify second user's chat message has arrived
...
Taken from documentation
I'm afraid it won't be possible to do what you need with WicketTester.
It starts one instance of the application. This is fine!
But it also acts like a browser, i.e. a single client.
I have used http://databene.org/contiperf for some perf tests (non-Wicket) before and I liked it. But if you try to use it with WicketTester then you either will have to have a separate WicketTester for each user or you will face synchronization issues in WicketTester itself.
I'd recommend you to use JMeter or Gatling. A user from the community made this integration: https://github.com/vanillasource/wicket-gatling. I haven't used it yet but I hope to try it soon.
I'm working on porting a desktop application (WinForm) to a web application (Java/Spring/JPA). The problems are many and I'm struggling a bit...
Now the problem is threading!
In the original application, that performs the export of certain data from the DB, there is a progress-bar indicating the progress of the process.
I want to port this progress-bar in the new web application. To do this I thought of using AJAX and use a separate thread to run the data export.
The main concerns are:
Am I following the right approach? Are there problems using multi-threading in web applications?
If during the export process F5 or refresh button are pressed what exactly happens? How can I stop the process?
How do I update the progress bar periodically? Do I have to make calls via ajax to the server?
I'm primarily an ASP.Net developer but from what I know of the HTTP protocol this just isn't the way to go about it. I've seen a lot of fairly clever solutions for this but in the end what becomes clear is that the HTTP protocol simply isn't designed to work like this.
Obviously you're aware that a flash or silverlight app would be able to do this but that comes with it's own set of issues.
Myself I prefer to keep all the weirdness on the server. In the past I've had to come up with a way to deliver several thousand emails through a web application and update the user on how it's coming along. I designed a set of tables to act as a queue. The web application would simply place any delivery requests in this queue and the progress bar would be determined by a request that checks the status of the items in the queue. Running in the background was a windows service which would also check this queue and was actually responsible for delivering the mail and setting the status of each item as it completed or failed.
It was a bit difficult to develop since windows services can be tricky but once it was up and running it was extremely smooth and reliable. Depending on your circumstances perhaps a simple scheduled task set to run every few minutes would do the trick for you.
I wouldn't necessarily jump straight to running a separate thread explicitly for the export. While it would be ideal to do this, the capability of the web container to do this is going to be a limiting factor. Your traditional Java EE app server generally discourages spawning threads for this (though you can hook up to a thread pool for this). Some containers are great at freeing up the threads from blocking until the work is done (Karaf with Jetty and Camel, for instance) so that they can service other web requests while the export is occurring. But my guess is that you're probably okay with the "start export" thread blocking until it receives a response.
How long does this export take? A couple of seconds, or are we talking closer to minutes here? If it's shorter, I'd think that just putting a little "Waiting" icon with the little circular spinner on it (using your favorite Ajax library, whatever that is) would be sufficient.
If you really want a true status bar that periodically refreshes itself, then yes you'd have to poll for it at some frequency. Presumably that could be a simple request that would load some kind of progress for the job from a database table for that job ID.
Find my answers Inline
I am following the right approach? Are there problem in using multi-threading in web applications?
-Yes you are on correct path. No there is no such problem in multi-threading in web application and its as easy as you do it in WinForm. Instead of using Dispatcher to update the UI, you would be making AJAX calls and with javascript DOM manipulation would take place.
If during the export process F5 or refresh button are pressed what exactly happens? How an I stop the process?
-Unfortunately there is no easy way. The standard way is, when such kind of processing is done and the user hits F5, you would show a dialog(with help of javascript) and inform user that the job is still running. If the user still wants to refresh then you have make another request to the server for cancelling the task.(You need to store thread id or cancellation token some where to cancel the task)
How do I update the progress bar periodically? Do I have to make calls via ajax to the server?
-The standard way is, generally you show show a loading image. IF you want to show a context senstive progress bar, it would mean you have to do polling. Here is an example by Dino Espito. Though its in ASP.NET, you could understand the underlying principle
Dino Espito
A part of my program needs to simulate a GPS. So I am setting up a client-server connection. Where on server my main application would run and on client it would send the GPS string periodically after a particular time interval. I am using JAVA for programming it and I am a bit new to networking area, so if someone can just give me an idea about How do i send my data periodically? The emphasis is on just one part. Periodically after a time interval.
you can use TimerTask Class for your solution. Here is a very useful link for its example.
In its run method you need to deploy your uploading code.
I am also working on same kind of project right now.
Add a java timer to your code that triggers at the interval you specify. In the timer handler, just run some code to send data to the server.
Use a TimerTask with a Timer.
Although your requirement might be simple enough, but i suggest you take a look into quartz scheduler.
It supports from plain simple timer tasks (like every minute or every xx seconds) to the more complex timing scenarios.
Here is one simple example that you can dive more deeply from the source code.
I am working on an application in Linux which will interfaces with hardware. One of the requirements is to create the GUI in Web-browser . the application will be c++ based. I m not familiar with web realted stuff so i want to know Is it possible to do such a thing (currently it's a console application take input from txt file/cmd line). gui will be simple using button and showing output messages on browser from the application. i want to know which technologies/languages are involved and how can it be done. some of the idea i read but havn't found anything concrete yet. if u have any idea about these or a better suggestion please share
run the app in background and communicate with browser ?
call library functions directly from browser ?
any other idea ?
I would start by setting up a regular HTTP server, like lighttp or Apache httpd.
You say you already have a command line program that does the actual work - As a first step, I would reuse that, and configure the web server to call your program using CGI - see forexample http://httpd.apache.org/docs/2.2/howto/cgi.html for apache
Finally, I'd pick some javascript framework like jQuery or YUI with Ajax capabilities to do requests to the server to call the CGI script from within a webpage. You could also create a form-based web application without ajax or any framework, but that would require you to stuff all kinds of logic in your program to generate HTML pages. By using Ajax, you can leave the command line application as is, and parse any responses it gives with javascript, and then use that to dynamically change the webpage in a way that would make sense to the user.
If this all works, then I would try to figure out how to package all these components. Perhaps you just want to create a simple archive with all the programs inside, or maybe you want to go as far as actually embedding the webserver in your program. Alternatively, you may want to do it the other way around and rewrite your program as an ISAPI module that you can plug into your webserver. Or if that's not integrated enough still you could write your own (partial) HTTP server. That's really up to you (I'd probably spend time and energy on searching for the leanest, meanest existing open source http serverr and use that instead)
At any rate, the prior steps won't be lost work. Most likely, developing the web page is going form a substantial part of the work, so I would probably create a quick and dirty working solution first using the age-old CGI trick, and then develop the webpage to my satisfaction. At that point you can already have an acceptable distributable solution by simply putting all programs in a single archive (of course you would have to tweak the webserver's configuration too, like changing the default port so it won't interfere with existing webservers.) Only after that I would spend time on creating a more integrated fancy solution.
I ended up using Wt though I'd update for future reference.
These are how I thought of doing this, in order of complexity for me:
Create a simple server-side-language (PHP/Python) website that can communicate with (ie launch and process the return of) your application
Modify your application to have a built-in webserver that just punched out HTML (command line parameters taken through the URL)
Modify the app to publish JSON and use javascript on a simple HTML page to pull it in.
You could write a Java applet (as you've tagged this thread) but I think you'd be wasting time. This can be quite simple if you're willing to spend 10 minutes looking up a few simple commands.
After 12 years, web browser-based GUI started to appear, WebUI is one of them.