Link to home
Start Free TrialLog in
Avatar of Sathish David  Kumar N
Sathish David Kumar NFlag for India

asked on

How to use loading image in Java/j2ee application


Hi,

How to use loading image in Java/j2ee application .  in my application i will submit the for m then i t will go to DB and do some transcation and update or insert the data . it take 10 to 30 sec ...

that time i want ask user to wait the process to complate . so i plan to display loading image how can i implement that !!
ASKER CERTIFIED SOLUTION
Avatar of colr__
colr__

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of rrz
rrz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sathish David  Kumar N

ASKER

@colr__: @ cmalakar:

I put the image in div tag in one jsp i include that jsp in all pages ...  but the gif file is not working , if i put the image in same page then that gif file is working fine ... why ? i am understand ...
@rrz@871311:

Most of my user are working in IE^ only . so i test the code but .. its not working ...
>its not working ...
What happens ?
I tested in IE8. It works for me.
Did you just copy and paste my code ? ( just change the image file name and put the file along side the JSP)
Avatar of colr__
colr__

Personally I think a javascript approach is better for this type of thing:

<img src='yourLoading.gif' style="display:none;" id='theImg' />

<form onsubmit="document.getElementById('theImg').style.display='block';">
...
</form>

Open in new window


The advantage of this is that you dont have to wait for thre posted form to begin to return - the loading image will display as soon as the user hits the submit button. By doing it in java you are also moving display-related stuff into your java code, which is not a good design.
colr makes some good points but I think it depends on the application.  It seems to me that server should be in control.
What if some of the form fields are invalid ?
>> I put the image in div tag in one jsp i include that jsp in all pages ...  but the gif file is not working

Can you show the code.. ?
This code in one jsp

<div id="imageDiv" >
                         
                         <img alt="processing...... " src="/x/img/cri4.gif" >  <b>Please Wait... </b>
                      </div>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link type="text/css" href="/xforcesTool/css/jquery-ui-1.8.12.custom.css" rel="stylesheet" />      
<script type="text/javascript" src="/xforcesTool/js/jquery-1.5.1.min.js"></script>
<script type="text/javascript" src="/xforcesTool/js/jquery-ui-1.8.12.custom.min.js"></script>

<script type="text/javascript">


$(document).ready(function(){
       
      $("div#imageDiv").hide();
          
      $("a").click(function(){      $("div#imageDiv").show(); });
            });



</script>

that above jsp inculed in my other jsp

when cilck button i call some java script method

in that method i write
$("div#imageDiv").show();

that image display but its not rotate (gif)
any input ??
I take it the gif rotates when viewed normally? Is the animation set to rotate indefinetly, or would it stop rotating after a specified time?

The reason I ask is that although the image is not visible as you've used hide() - the image is still there and rotating in the background. So if the gif is set to animate for only a set period of time, that time may have elapsed by the time you're calling show()
>>$("div#imageDiv").show();

When is this being executed.. after submitting the form or before ?

You can comment out the form submission code and see, if the image really rotates or not, with the above code.
if i put in same page means it will rotates put i inculde the image it wont rotate.
>>if i put in same page means it will rotates put i inculde the image it wont rotate.

including one jsp in other is something that gets executed at server. Client is not aware of that includes.

All that you should see is

   1) In both include and don't include cases,  does the images urls that you get to the client are same ?

   2)  When you include another jsp, On clicking the submit button if you just show the image without form submission , does the image really rotates or not ?