Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Image while loading a page

 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am using Struts 1.2

I want to generate a GIF on a page to say sth is loading

The original scenario is i have a page which on submit opens a popup and displays data.But the data takes a lot of time to come on the page
So in the mean while i want to show a GIF on the popup to show its loading

Please help
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone suggest me any possible solutions please
 
Mohana Rao Sv
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In struts 2 we can achieve that using waitAndExecute interceptor. Figure out how to do it struts 1.2.
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions for Struts1.2 please
 
seshu Palamanti
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a similar problem and was able to do using a this way and it works



function gowait() {
document.getElementById("main").style.visibility="hidden";
document.getElementById("wait").style.visibility="visible";
window.setTimeout('showProgress()', 500);
}
function showProgress(){
var wg = document.getElementById("progressbar");
wg.src=wg.src;
}


<html:form action="/yourAction.do" onsubmit="gowait();">

<div id="main">
your contents that will wait
</div>

<div id="wait" style="visibility:hidden; position: float; top: 0; left: 0">
<div id="center250b">

<div id="fixedtop2">
<table >
<tr><td ><font color = #FFFFFF face ="Garamond" size="5"><h2>Please wait....</h2></font></td></tr>
<tr>
<td >
<img id="progressbar">
</td>
</tr>
</table>
</div>

</div>
</div>
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way you have coded...You have both the items on the same page

I mean the image to show that your data is loading and the activity which happens before the image is shown

But the requirement which i have is in such a way that.....There are two individual pages....

Once a button is pressed on a JSP (1st page) a new window opens up......which shows the result((Second page)Image has to be shown on this page)
 
seshu Palamanti
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you would have to use a java script that opens a window which contains your loading image and in the page add another function that closes window when it refreshes with the result. You would have to set a flag in the response when you finish rendering your page and use to toggle the loading window.
[code=java][/code]



function openWinLoader()
{
if(win_name == null)
win_name=window.open('jsp/LoadPage.jsp','Loading' ,'status=no,scrollbars=no, resizable=no,menubar=no,top=300,left=300,height=200,width=400');
else
{
//if(!win_name.open)
win_name=window.open('jsp/LoadPage.html','Loading' ,'status=no,scrollbars=no, resizable=no,menubar=no,top=300,left=300,height=200,width=400');
}
}
openWinLoader();
function closeWindow()
{
if(win_name.closed)
{
return ;
}
win_name.close();
}




window.onLoad="setDefault()"
function setDefault()
{
var sFlag = "<%=sFlag%>";
if(sFlag == 1)
{
closeWindow()
return
}


}

function submitForm(theForm)
{

openWinLoader();
}
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey i have tried what you have suggested...But i think am missing something here

I have a JSP(which i am on right now...I open a new window from here,this window shows the result data...which takes time to load)

I call function openWinLoader() from the JSP which i am on right now
but inside the function you have win_name you are doing a null check on
initially there is no window....???

According to your code do you open the window with a image first and then close it when you get data on the other one???
OR
both the windows one with the image and the other with the result open initially and then the one with image closes later on??


Can you just elaborate on which piece of code to put on which page(Sorry am still new to JavaScript so had to dig through it...)

Thank you for the suggestion

 
seshu Palamanti
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The initial page loads and there are no windows the user submits the page then you call openwindow which opens the loading image, your backend process goes on and takes some time and finally when the page returns (results page) the results page contains the code to close the window. You also use a mechanism to close the window only by the results page and hence the toggle logic. The code i put it there is just give you an idea please dont take the code literally. It all depends on how how your page flow works. Hope this helps.
 
surya naidu
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seshu Palamanti wrote:The initial page loads and there are no windows the user submits the page then you call openwindow which opens the loading image, your backend process goes on and takes some time and finally when the page returns (results page) the results page contains the code to close the window. You also use a mechanism to close the window only by the results page and hence the toggle logic. The code i put it there is just give you an idea please dont take the code literally. It all depends on how how your page flow works. Hope this helps.



But when i open the image page and the request goes to action class to process the results......How do i set the mapping.findforward???
 
seshu Palamanti
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The popup window for loading image has no forward you will forward after processing your results to your result page, that page will have logic to close the window
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic