aspose file tools*
The moose likes Struts and the fly likes Progress bar in a JSP onClick event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Progress bar in a JSP onClick event" Watch "Progress bar in a JSP onClick event" New topic
Author

Progress bar in a JSP onClick event

Pratheek Patel
Greenhorn

Joined: Feb 18, 2008
Posts: 14
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

Joined: Feb 29, 2008
Posts: 1000
    
    1

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


Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1000
    
    1

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

Joined: Oct 29, 2001
Posts: 8710
    
    6

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.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Pratheek Patel
Greenhorn

Joined: Feb 18, 2008
Posts: 14
Abhay,Joe

Thanks very much for your suggestions...

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

>Thanks
Pratheek Patel
Greenhorn

Joined: Feb 18, 2008
Posts: 14
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

Joined: Feb 29, 2008
Posts: 1000
    
    1

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
 
wood burning stoves
 
subject: Progress bar in a JSP onClick event
 
Similar Threads
Progress bar in JSF
How to implement a rich:datatable that shows popup with message “Sorting in progress”
Jtable Event Handling
Javascript validation
javascript/jsp