-
1. Re: Help with rich:progressBar.
silverjam Apr 30, 2008 3:12 AM (in response to djkrite)Did you ever solve this?
-
2. Re: Help with rich:progressBar.
silverjam Apr 30, 2008 3:57 AM (in response to djkrite)I cannot get it to work as well.
The idea is that I'm having a commandButton. When the user hits this button, a long task starts.
I am uncertain on how I should call the task execution (through ActionListener or Action?). I have tried to enable the progressBar on the ActionListener and subsequently call the task on the Action, while having a reRender="progressBar" on the commandButton. However this doesn't give anything.
Should the task be started on its own thread from inside the backingbean, or?
The progressBar example in the livedemo is okay, but pretty useless since it's just reading the timestamp. Anybody have a real example?
Best regards,
Morten :-) -
3. Re: Help with rich:progressBar.
andrei_exadel Apr 30, 2008 5:42 AM (in response to djkrite)If progressBar is enable and progressbar's value was updating by any process It should show appropriate progress on the page.
You understand that value should be in session scope.
If you cannot fire it please post your code here. -
4. Re: Help with rich:progressBar.
silverjam Apr 30, 2008 6:29 AM (in response to djkrite)"andrei_exadel" wrote:
If progressBar is enable and progressbar's value was updating by any process It should show appropriate progress on the page.
You understand that value should be in session scope.
Backingbean is in session scope yes.
Will it work if the task runs inside the Action or ActionListener on my commandButton, or do I need to start a thread from inside one of these methods?
Task is updating backingbean-wide variable, which has a public property that the progressBar should read.
~Morten :-) -
5. Re: Help with rich:progressBar.
andrei_exadel Apr 30, 2008 6:37 AM (in response to djkrite)I don't need start any addition thread.
You should start your process in actionListener or action of your command button. If progressBar was disabled it should be rerendered as enabled after process was started. Be sure that progressBar in ajax mode.
Then polling should be run. You can see it in FilreBug console.
If polling is in ptogress but progressBar does not show it - seems that progressBar's value is not updating properlly. -
6. Re: Help with rich:progressBar.
djkrite May 13, 2008 11:01 AM (in response to djkrite)I'm still struggling to get this working. I have some sample code below:
Component on view:<rich:progressBar mode="ajax" value="#{ManagedProgressBar.progress}" label="#{ManagedProgressBar.progress} %" minValue="-1" /> <h:commandLink action="#{TestBacking.startProgressBar}" value="Start Progress Bar" />
Backing logic:public class Test { private ProgressBar progressBar; private Timer timer; private int progress; public void startProgressBar() { timer = new Timer(); progressBar = new ProgressBar(50); progress = 100; timer.schedule(new Task(), progress * 1000); } class Task extends TimerTask { public void run() { progressBar.setProgress(progress); } } }
Model (session managed):public class ProgressBar { public int progress; private boolean render; public ProgressBar(int progress) { this.progress = progress; } public int getProgress() { return progress; } public void setProgress(int progress) { this.progress = progress; } public boolean isRender() { return render; } public void setRender(boolean render) { this.render = render; } }
My progress bar just sits at 0 and never updates. What am I doing wrong? -
7. Re: Help with rich:progressBar.
andrei_exadel May 14, 2008 4:16 AM (in response to djkrite)You must set up enabled attibute in true value to start polling.
-
8. Re: Help with rich:progressBar.
djkrite May 14, 2008 9:07 AM (in response to djkrite)On this page is states the default value is true: http://livedemo.exadel.com/richfaces-demo/richfaces/progressBar.jsf (see tag info).
I tried this it still doesn't work:<rich:progressBar enabled="true" mode="ajax" value="#{ManagedProgressBar.progress}" label="#{ManagedProgressBar.progress} %" minValue="-1" /> <h:commandLink action="#{TestBacking.startProgressBar}" value="Start Progress Bar" />
-
9. Re: Help with rich:progressBar.
andrei_exadel May 14, 2008 9:13 AM (in response to djkrite)What JSF implementation do you use?
-
-
11. Re: Help with rich:progressBar.
djkrite May 20, 2008 8:45 AM (in response to djkrite)got this working using the demo source code.
-
12. Re: Help with rich:progressBar.
djheath Jun 11, 2008 12:49 PM (in response to djkrite)I am having the exact same problem. I'm using Richfaces 3.2.1 with the Sun RI of JSF 1.2
test.xhtml:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich" xml:lang="en" lang="en" > <ui:component> <a4j:form id="testForm"> <rich:panel id="panel"> <rich:progressBar value="#{testBean.progress}" mode="ajax" /> <a4j:commandButton id="go" value="Go" actionListener="#{testBean.go}" disabled="#{testBean.isProcessing}" onclick="this.disabled=true" oncomplete="this.disabled=false" enabled="true" mode="ajax"/> </rich:panel> </a4j:form> </ui:component> </html>
backing bean:import javax.faces.event.ActionEvent; public class TestBean { private Long progress; private Boolean isProcessing; public Boolean getIsProcessing() { return isProcessing; } public void setIsProcessing(Boolean isProcessing) { this.isProcessing = isProcessing; } public Long getProgress() { return progress; } public void setProgress(Long progress) { this.progress = progress; } public void go(ActionEvent event) { isProcessing = true; progress = 0L; long totalCount = 1000000000; for (long i = 0; i < totalCount; i++) { progress = i / totalCount * 100; } isProcessing = false; progress = 0L; } }
This is just a test to simulate a lengthy operation, but there is absolutely no feedback on the front end.
Can someone PLEASE post a real-world example that can actually be of use instead of the trite examples on the livedemo site? Thanks -
13. Re: Help with rich:progressBar.
djkrite Jun 11, 2008 3:42 PM (in response to djkrite)did you check out the demo source code? i copied the code straight over and it worked fine for me.
TK -
14. Re: Help with rich:progressBar.
djheath Jun 11, 2008 4:48 PM (in response to djkrite)yeah, i looked at the demo source code but it's pretty weak. The code assumes that you can perform the task at hand within the getter of your bean which is bad design.
I have a *very* lengthy task that needs to run for minutes and using this pattern is just not feasible.