Announcement Announcement Module
Collapse
No announcement yet.
Progress bar implementation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Progress bar implementation

    I am trying to implement progress bar. Here instead of bar I am trying to display numbers i.e., 1%, 2%, ....so on till 100%.
    For this, I am using one bean class, one controller and one jsp.
    The controller is:
    Code:
    public class SyncProgressController extends AbstractController implements
    InitializingBean
    {
    	private static final Logger log = Logger.getLogger(SyncProgressController.class);
    	
    	@Override
    	protected ModelAndView handleRequestInternal(HttpServletRequest req,HttpServletResponse res) throws Exception {
    		SyncProgress syncProgress;		
    		int progressStatus = 0;				
    		for(int i=0;i<100;++i)
    		{
    			syncProgress = new SyncProgress();
    			syncProgress.run();
    			progressStatus = i;
    			WebUtils.setSessionAttribute(req,"progressStatus",progressStatus);
    		}
    		return new ModelAndView("SyncProgressView"); 
    	}
    
    	public void afterPropertiesSet() throws Exception {
    		// TODO Auto-generated method stub
    		
    	}
    	
    
    }
    The jsp is SyncProgress.jsp
    Code:
    <c:out value="${progressStatus}"/> % is completed
    <c:redirect url="SyncProgressO.htm"/>
    The bean class is SyncProgress.java:
    Code:
    public class SyncProgress extends Thread
    {
    	private static final Logger  log4log = Logger.getLogger(SyncProgress.class);
    	
    	 public void run() 
    	 {
    		 try
    		 {
    			 Thread.sleep(1000);
    		 }catch (InterruptedException e) 
    		 {
    			;
    	     }
    	 }
    	
    }
    The output I am getting is(directly):
    Code:
    100% is completed.
    But I want the other numbers before 100 also to be displayed.
    Like 1% is completed, .. each time after 1second of sleep the percentage number in the jsp has to be updated. How do I do this?
    I know that:
    First, if I call the controller every time, progressStatus will be initialized to 0.
    Second, there is no intermediate call to the jsp. It is right that only after it reaches 100, it will call the jsp.
    I know that the implementation what I tried is wrong, I hope some (I thank them in advance) will help in correcting the implemenation so that I will be successful in implementing the "Progress Bar".
Working...
X