I´m going crazy trying to include a progress bar during a long time process execution.
I can display a waiting page, a spinning wheel and so on, but I cannot find the way to put a real progress bar that inform the user about the percent to finish.
To be more exhaustive, I have a button that calls a method that insert lots of info on the DB. During this process, I am updating a variable with info about the progress (Imported 3 users from 1500, Imported 4 users from 1500, ...), and would be fantastic to show this info to the user instaed a spinning wheel, using for example a Timed Action builder in this case.
I try everything. Developing a thread seems to give good results, but inside it I cannot use the webAppAccess object, so I cannot go this way.
Anybody knows how can I do that?
THank you very much, best regards.
NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
This topic has been locked.
9 replies Latest Post - 2012-11-16T11:20:25Z by rhakaro
Pinned topic Show real Progress Bar in long time process
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-11-16T11:20:25Z at 2012-11-16T11:20:25Z by rhakaro
Re: Show real Progress Bar in long time process2012-11-13T17:25:17Z in response to rhakaroHi Sam, thanks for answer.
I thought that and try it, but I couldn´t make it works. When I click the button, the long time method begins and it seems that I cannot do anything more until it finish, like refresh the info in the page.
mburati 060000VQ202552 PostsACCEPTED ANSWER
Re: Show real Progress Bar in long time process2012-11-14T16:09:08Z in response to rhakaroThanks for helping out here Sam!
In the meantime, I do want to point out that it's usually not a good idea to execute long running tasks directly in an http servlet or portlet request, as http requests are usually designed for fairly quick turnaround. The browser may not want to wait for the request to complete and you may be using up one of the server's connection threads from its connection thread pool during that time etc. It's also not a good idea to spawn threads from an http servlet or portlet request (I believe the j2ee spec discourages it and in some cases may prevent it).
If it's a fairly long running task, then it may be better to do it out of band of the http request, such as via a WebSphere worker object (via straight Java or EJB/MDB) kicked off from a WEF action or via other backend task initiated by an action in the WEF app, but which runs out of band of the initial http request itself. That backend worker could then have a method on it that allows callers to retrieve the progress status, which you could check via Timed Action if desired.
I hope that info helps,
The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
Re: Show real Progress Bar in long time process2012-11-14T19:45:10Z in response to rhakaroAlas, after talking with colleagues, this is a bit more complex than I initially thought. The idea I originally had in mind was flawed. :-) Originally I thought about firing an AJAX GET request to a long server side action (which would do long work and update a session variable along the way) and immediately begin firing period AJAX requests to get the current progress as a number. However, in Firefox, the second ajax request blocks until the first one is complete.
This is what I plan to try, but in the meantime I encourage you to look into this technique or perhaps a better one, since my time to do samples is limited. There are many approaches to doing this. Some are complex to configure; some have side effects you don't want; others don't work with your tooling such as Web Experience Factory (for example, there's a new HTML5 features called WebSockets, but the server side portion wouldn't currently work with WEF)
There is a really good three part series on Reverse AJAX techniques here, which gave me the idea of trying the Hidden iFrame technique:
Let us know how it goes and if I can get a sample done in a timely manner, I'll post here.
Opinions and thoughts my own, not necessarily IBM's.
Re: Show real Progress Bar in long time process2012-11-15T10:18:52Z in response to SystemAdminHi mburati and Sam,
Thank you very much. Thinking about mburati´s post, I´m going to cut the long time process in two or three parts for the moment, showing screens to the user reporting about the operations are being executing.
The solution that you propose, Sam, are very interesting and I will try it using a blank model and simulating a long process with a loop.
When I have more info, I´ll post it here.
Re: Show real Progress Bar in long time process2012-11-15T14:48:43Z in response to rhakaroBreaking the screens and process apart and giving the user feedback sounds like the right approach.
Also, I ran across this, which you might want to look at:
Leveraging Reverse AJAX in IBM WebSphere Portal 7.0 using Dojo CometD and Web messaging service
It looks like a complex configuration, but might be worth it depending on your requirements. And it appears you can integrate this approach with Web Experience Factory applications.
Like mburati mentioned, web transactions are supposed to be fast. But I can see use cases where you want to show a progress bar. And like I mentioned, each Reverse AJAX technique has advantages and disadvantages.
My postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
Re: Show real Progress Bar in long time process2012-11-16T11:20:25Z in response to SystemAdminOk Sam, it seems to be exactly what I was looking for. Thanks for the link, it is very explicit about the development process.
I will try and give you the update.