cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need an example for a progress bar

Former Member
0 Likes
581

Hello,

One of the DynPro UI's is a progress bar.

I have a certain view which loads a ResultSet from a certain DB. This ResultSet is being loaded to the view in a while(rs.next()) loop and since it contains huge amount of records it takes it few minutes to load.

Can someone please show me an example of how can integrate such a progress bar in the view which will display the amount of time left for loading?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi,

There wont be a direct way to get it.. You can get the system time before and after the execution of the query and play with it.. For every pass through while(rs.next()).. u can get the system time,subtract it from initial time and set the bar percentage value proportionally...It will simulate a progress bar like scenario....

System time can be obtained by System.currentTimeMillis().

regards

Bharathwaj

Former Member
0 Likes

hello Bharathwaj

but i think rs.next() will execute only after the whole resultset is loaded. also after every rs.next() u need to refresh the page. that will take a lot of time to show the result page.

regards,

Piyush.

Former Member
0 Likes

Hey Bharathwaj,

But how can I know in advance the system time after the execution...?

Former Member
0 Likes

hello Roy,

let me give u an example:

long startTime = System.currentTimeMillis(); //line1

rs = pr.excuteQuery(); // line2

long stopTime = System.currentTimeMillis(); // line3

now u ll get the stopTime only after the the execution of line2 is complete, ie all the resultset is loaded. so now there is not use of the progress bar.

regards,

Piyush.

Answers (2)

Answers (2)

Former Member
0 Likes

Roy,

Sadly, ProgressBar in WD is suitable for displaying some 'static' percent value rather then for real-time visualization of process' progress. The problem is in fact that separate HTTP request/response round-trip required to update values of UI element (incl. ProgressBar) and there is no way in HTTP to push-back content to browser.

Also you can do this but it is strictly unrecommended in J2EE application (due to use of multithreading):

1. In first request/response cycle (some WD action) you set up Timer UI control and fork new thread that perform loading of data.

2. In subsequent requests (as a result of Timer.onTimer action execution) you poll thread for progress via some variable shared between 2 threads and update progress bar accordingly

3. If on next timer invocation the work is done, you are navigating to result or populate context to show result or whatever. DO NOT MODIFY WD CONTEXT OR INVOKE CONTROLLERS METHODS FROM SEPARATE THREAD!

VS

Former Member
0 Likes

I see, so I beleive I will pass this feature.

Former Member
0 Likes

hello Roy,

a progress bar can only be shown if the view gets refreshed periodically. when the resultset is being loaded the view will only be refreshed when the whole resultset is loaded and the method terminates.

or what you can do is make an extra Thread to load the resultset and show the progress bar using ProgressIndicator UIE and TimedTrigger UIE.

one more thing, in case of resultset i think there is no way to find the current status of the resultset. u can know the total no. of records in it.

regards,

Piyush.