Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server side - Progress Bar

I am currently working on a file conversion program, once the file has been uploaded it will convert the file to different file formats(ppt,pdf) this will usually take long depending on the file size. Since the file conversion is happening on the back end, I want the user to see the progress of the file conversion( something like progress bar eg "52% file being converted") is there anyway I can display to the user the current progress of the file conversion(that's happening on the back end)? During file conversion I am only able to show the status(in numbers(provided by the API I am using))

I have no idea where to start can someone provide some insight or approach?

like image 978
user962206 Avatar asked Dec 29 '12 11:12

user962206


2 Answers

If you are using Struts2 take a look at Execute and Wait Interceptor. It creates new thread with your task which will be executed in the background while you can show some progress to the user.

In struts.xml file add execAndWait interceptor to your long running action and define two results wait and success.

<action name="longRunningAction" class="...">
  <interceptor-ref name="defaultStack"/>
  <interceptor-ref name="execAndWait"/>
  <result name="wait">longRunningAction-wait.jsp</result>
  <result name="success">longRunningAction-success.jsp</result>
</action>

You still need to poll this action in your JSP via AJAX or simple page refresh.

like image 51
Aleksandr M Avatar answered Nov 10 '22 22:11

Aleksandr M


You're saying: During file conversion I am only able to show the status(in numbers(provided by the API I am using))

What is this number? Is percentage of how much of a file is converted? If it is, then you only need to import jQuery UI library and add .progressbar()

like image 1
Kristjan O. Avatar answered Nov 10 '22 22:11

Kristjan O.