Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Progress bar in a JSP onClick event

 
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
 
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
 
Bartender
Posts: 9612
16
Mac OS X Linux 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
 
Did you miss me? Did you miss this tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic