KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > javaee > blueprints > progressbar > ProgressBarBean


1 /* Copyright 2005 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at: http://developer.sun.com/berkeley_license.html
2  */

3
4 /*
5  * $Id: ProgressBarBean.java,v 1.1 2006/06/20 01:08:12 inder Exp $
6  */

7  
8 package com.sun.javaee.blueprints.progressbar;
9
10 import java.util.Random JavaDoc;
11 import javax.faces.context.FacesContext;
12
13 public class ProgressBarBean {
14     
15     public ProgressBarBean() {
16     }
17     
18     private int percentage=0, increment=10;
19     private boolean running=false;
20     
21     public int getPercentage() {
22         if(running) {
23             if (percentage >= 100) {
24                 percentage=100;
25                 running=false;
26             } else {
27                 percentage += increment;
28             }
29         }
30         return percentage;
31     }
32     
33     
34     public void startTask(FacesContext context) {
35         percentage=0;
36         running=true;
37     }
38     
39 }
40
Popular Tags