• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Progress bar in a JSP onClick event

 
Pratheek Patel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
How would i implement a progress bar in a JSP when onClick event is fired.
I have a link in JSP, which calls struts action class &finally it displays result JSP when onclick is fired.
In between this process, i need to display a progress bar to the user.

Any help is highly appreciated.

Thanks
Purna
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have implemented this functionality .....long time back ..so remember a small bit of it ..

On onClick() event , instead of directly calling your Action [ /abc/xyz/pqr.do ] , call a javascript function.

This javascript function is defined in the same jsp.

This javascript function will , in turn , submit your form.

1. Before placing your logic in javascript function, add a html div tag with an id [ <div id = "progressID"> </div> ] around a portion/section of JSP where you want to show Progress bar.

2. Have a boolean variable at Session level which is initially set to "false" [ which means that your Action is not completed ] so
place a logic in your java script function like

if (!isActionCompleted)
{
// show div tag contents means your progress bar
}
else
{
// show div tag contents means your progress bar
}

~ Thanks
Abhay
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry , i forget to add ....


Once your Action is completed and data is ready to show back to JSP , set that Boolean variable to "true".
This will hide your Progress Bar.

For the solution , i am assuming you have a Progress bar code with you .....

~ Abhay
 
Joe Ess
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at ExecuteAndWaitInterceptor
The ExecuteAndWaitInterceptor is great for running long-lived actions in the background while showing the user a nice progress meter.
 
Pratheek Patel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhay,Joe

Thanks very much for your suggestions...

I will come back to you, if any queries in implementation.

>Thanks
 
Pratheek Patel
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abhay,
I coded every thing, except setting the isActionComepleted session attribute.
How can i check the session attribute in the javascript, because javascript doen't have handle on the session.

Waiting for your reply.

Thanks
>SS
 
Abhay Agarwal
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Set "isActionCompleted" variable to "true" in your Action Class...
as, i think , from your Action Class ...you will be directing to either "success" or "failure". So,

for eg -

Action Class Code

////////////////////
.
.
.
.
if (success)
{
isActionConpleted = true;
}
else
{
isActionConpleted = false;
}
.
.
.
////////////////////

When you send "success" back to JSP , set it to "true".

Now , when request goes back to JSP , "isActionCompleted" variable will be "true" ..so ..."Hide Progress Bar" Code will be called ...

~ Abhay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic