Can I use outputProgress to display the progress of a long running business process?
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icefaces.org  [Register] Register  [Login] Login 
Can I use outputProgress to display the progress of a long running business process?  XML
Forum Index -> JBoss Seam Integration Go to Page: 1, 2 Next 
Author Message
jonne

Joined: 16/11/2008 00:00:00
Messages: 17
Offline


Hi,

In my application I want to insert a large amount of data in a database. The files are first uploaded using an icefaces inputFile component with a first progressbar. This works great.

But what would be a good strategy to create a second progressbar that informs the user about the progress of the long-running business process that inserts the data?

In the seam examples the use of a progressbar is illustrated by first creating a thread pool with a thread that updates the view with a fixed interval.

It would be nice to be able to use Seam's @Asynchronous annotation and launch a function that makes the render manager update the view once per second? But the problem here is that seam loses all the contexts except the business context... I can't use the RenderManager anymore!
jguglielmin

Joined: 20/07/2007 00:00:00
Messages: 181
Offline


ICEfaces is already processing asynchronously if you set the context param (in web.xml) for synchronous to false. You don't need the annotation to do so.

I would suggest having a second progress monitor for the database process and use component-binding to update this process bar. (using an indeterminate progress bar unless you have some way to determine the % progress??)

Keep in mind that the ajax calls are light and in order to keep them this way, you don't really want the heaviness of all Seam contexts, tx management, etc. This means that injection won't always find what you want in the Seam context when you are using push (progress monitor). You would probably want to look up the component using the findComponent method of the D2DViewHandler and do this event-scoped. If you haven't checked out the DataPaginator example in seam-comp-showcase, you might want to.
jonne

Joined: 16/11/2008 00:00:00
Messages: 17
Offline


Thanks for your quick reply!

So what you propose is a solution without the RenderManager?
Do I still need a thread with a sleep function like in the progressbar example?
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1196
Offline


Actually, to use the RenderManager but looking at your use case description again, you could just have 2 progress monitors, 1 for fileupload and another for your database processes. In your backing bean, you would have attributes, progressFileupload (value bound to first progress bar) and progressData (value bound to second progress bar).

you could then trigger the second progress bar from the actionListener of fileupload (get the first push for free). If you have a series of Database activities, you can then push an integer after each successful stage, or use the indefinite progress monitor and just push it complete at the end (or in case of an exception). There are ways to find reference to the RenderManager (is this what you are losing on each push?)1) on your getter for this object, if it's null, keep a copy of a reference in the constructor of your bean or do a component.getInstance("RenderManager") in the constructor to keep a saved copy of this reference.

Component-binding may be ok for 1.7, but I guess 1.8 this won't be ideal (with advent of state-saving) so perhaps best to use the RenderManager.

jonne

Joined: 16/11/2008 00:00:00
Messages: 17
Offline


I'm close, the RenderManager does it's job, but there is an issue I can't solve:

The problem is that the business process can be long running, maybe even for more than 10 minutes. When I launch the process by clicking a button on the webpage, Icefaces waits for the process to finish before updating the view. I can make a separate parallel thread request updates of the view, just like in the outputProgress example, but those requests will never reach the browser. The application is still waiting for a response for the button action. So for a long running process the browser will time out and the Icefaces connection status will show that it lost the connection...

In seam one could solve this by using the @Asynchronous annotation: just launch the process and it will continue in the background.

How can I do this in IceFaces?
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1196
Offline


That shouldn't happen (initial request is getting blocked somewhere?). Perhaps the thread isn't being launched correctly. Do you have a simple example app that you can post here?
jonne

Joined: 16/11/2008 00:00:00
Messages: 17
Offline


I have finally solved my problem with a combination of two threads. The first is based on the outputProgress example. It will repeatedly update the progressbar's state, until the second thread - the one that imports a file in the database - has finished it's work. While the second thread is running it constantly calculates the progress and sends it's value to the first thread. The first thread only updates the progress bar with this value two times per second.
I did use the @Asynchronous annotation, it was the only way I found to run a process in the background.
You will find parts of the code in the attached files.
 Filename importprogress.txt [Disk] Download
 Description
 Filesize 6 Kbytes
 Downloaded:  543 time(s)

walwal

Joined: 20/05/2009 00:00:00
Messages: 8
Offline


Dear all,
I can not get the sample provided in the tutoruials work. I am getting exception:

com.icesoft.faces.webapp.xmlhttp.FatalRenderingException: fatal render failure for View[NKkkxRWMUVoBkwcdM1zBFw:1]
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.fatalRenderingException(PersistentFacesState.java:506)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.failIfDisposed(PersistentFacesState.java:538)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.render(PersistentFacesState.java:167)
at com.icesoft.icefaces.tutorial.component.outputProgress.mode.ProgressBar$1.run(ProgressBar.java:78)

here my project done in netbeans.

I spend several days tryonig to make it works but no wway to do that.



jguglielmin

Joined: 20/07/2007 00:00:00
Messages: 181
Offline


Are you using Seam (can we make that assumption, seeing as how you posted on the jboss-seam integration part of the ICEfaces forum)? Thread management is different when using Seam as scopes are varied. Since you are using Netbeans and mention the tutorial, you might be better off posting in another part of the forum. (If it's Netbeans related, try posting it on Tools, or if it's a component problem, try Components, etc). You might also want to mention which version of ICEfaces, jsf, which application server, etc. But from the (very) brief snippet of your exception, you might want to ensure that you have a non-null RenderManager as well. Check configuration first.
walwal

Joined: 20/05/2009 00:00:00
Messages: 8
Offline


Hi, I think the problem is in the rendermanager. Could you please explain me what to do to get around this exception.
I am not using seam (only icefaces and netbeans last versions) but the error occur when the code execute :the line
state.render();
in the turotial of progress bar mode.
Do you have a working example

here is my project. could you please help me to get it work. it is exactly the same as what we have in the tuto.

thanks
 Filename outputProgress-mode-tutorial.zip [Disk] Download
 Description
 Filesize 10289 Kbytes
 Downloaded:  176 time(s)

s.tzoannos

Joined: 14/04/2009 00:00:00
Messages: 3
Offline


Hi! I have exactly the same problem with exception:

com.icesoft.faces.facelets.D2DFaceletViewHandler renderResponse
SEVERE: Problem in renderResponse: null
java.lang.NullPointerException
at com.icesoft.faces.facelets.D2DFaceletViewHandler.renderResponse(D2DFaceletViewHandler.java:257)
at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:109)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.render(PersistentFacesState.java:175)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.executeAndRender(PersistentFacesState.java:299)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState.setupAndExecuteAndRender(PersistentFacesState.java:310)
at com.icesoft.faces.webapp.xmlhttp.PersistentFacesState$RenderRunner.run(PersistentFacesState.java:429)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:643)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:668)
at java.lang.Thread.run(Thread.java:619)
3 ???? 2009 4:22:31 ?? com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: ) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@b38dba]
out - percentage:100
in - percentage:100
3 ???? 2009 4:22:31 ?? com.sun.faces.lifecycle.Phase doPhase
SEVERE: JSF1054: (Phase ID: INVOKE_APPLICATION 5, View ID: ) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@b38dba]


I have searched a lot for a solution without success. Does anyone have any suggestion?



jguglielmin

Joined: 20/07/2007 00:00:00
Messages: 181
Offline


This is not related to Seam, please see General Forum Posting
leonbnu

Joined: 19/05/2009 00:00:00
Messages: 16
Offline


Hi,
I was actually experimenting a similar case. I launched a long running business process using @Asynchronous method, then inside this business method, I actually didn't push the progress to outputprogress directly(although you could). Instead, to make it more fun, I raised an asynchronous event inside the long running process to notify an observer to update the view. It worked.

So yes, you can use @Asynchronous method to do this. But the ugly part is that you need to pass all the necessary objects around.


The only problem I'm trying to figure out now is how to display FacesMessages for the outputprogress component. This is for notifying the long running process status to the user.
judy.guglielmin

Joined: 20/02/2007 00:00:00
Messages: 1196
Offline


I'm not sure that faces messages would be the correct way to do this as they are only event-scoped. (each push to the progress monitor is an event). Are you using the properties on the progress monitor for this (label and labelComplete)?
Once it is finished (or there is an exception or error), you could then queue the faces messages (is this what you are referring to having problems with?)
brad.kroeger

Joined: 26/10/2004 00:00:00
Messages: 295
Offline


FYI, an "Async Progress" tag has been added to ICEpack. This tag uses an indeterminate ice:outputProgress component to monitor the progress of a server side Runnable.

Brad Kroeger
Developer
ICEsoft Technologies, Inc.
[Email]
 
Forum Index -> JBoss Seam Integration Go to Page: 1, 2 Next 
Go to:   
Powered by JForum 2.1.7ice © JForum Team