PDA

View Full Version : Wait screen?



cnelson
Jun 21st, 2005, 04:11 PM
I'm trying to use SWF in a project for the first time because I have a semi-complicated flow of pages that is dynamic in nature.

One of the paths through the flow involves a step that may take as long as a minute or two. I would like to show a wait screen during this time. When the back-ground process is complete, I would like the wait screen to forward to the next page.

Any suggestions as to how best accomplish this with SWF? I guess the wait screen could refresh itself every N seconds, and once the background process is complete, show the next page.

Any help, examples, or suggestions would be appreciated.

Christian

sethladd
Jul 7th, 2005, 08:23 PM
While I'm not sure how to integrate this into Web Flow itself, we do have a simple trick for these types of long process pages.

We'll spawn a thread, and pass in the user's session to the thread. The thread will put a token into the session. The wait page will continually check for this token to signify the work is done.

With JDK 1.5's new concurrency stuff, this becomes even easier. But the trick is the same.

kenevel
Jul 13th, 2005, 10:53 AM
Hi there,

This is probably a bit late but we solved this problem a while ago as follows:

- User submits form
- immediately return a "please wait" page, but rewrite all the request parameters as hidden input tags within a form
- attach an onload handler to the body element which immediately submits that form
- the server will only return the results once the processing is finished, and in the meantime the user has the "please wait" page to look at.

Hope this helps! Plus it has the benefit of not breaking the single thread model in your servlet container.

Cheers

Mike

Colin Yates
Jul 13th, 2005, 11:34 AM
Hey kenevel, I like that idea :)

I have previously achieved this using JMS, but your idea is so much nicer. Could probably be implemented without too much intrusion as well :)

kenevel
Jul 14th, 2005, 05:30 AM
Title says it all... thanks Yatesco!

porcelli
Feb 13th, 2006, 09:29 AM
I´d like to come back this thread alive and ask:

Using a thread model as sethladd said, is it possible to create a "cancel" operation? If yes, how?

Regards,
Alexandre Porcelli

lotusbloats
Feb 13th, 2006, 12:37 PM
I don't think WebFlow has any concept of a "wait page", but OpenSymphony's WebWork does. I recommend you check out their codebase and see if you can adapt their pattern to your need.

porcelli
Feb 15th, 2006, 07:30 AM
I´m not looking for a wait page, but a way to cancel a execution. Is it possible using a thread model explained by sethladd?

Any sugestion?

benbuchanan
Oct 25th, 2006, 07:18 PM
I'm using Kenevel's suggestions to create a wait page which works well apart from one thing - I can't get an animated gif on the page to play while the submit is in progress. Has anyone else tried to use an animated gif on a wait page? How did you get it to play?
Thanks
Ben

klr8
Oct 26th, 2006, 12:55 AM
The browser will suspend all animation threads once the entire page is submitted. One trick I know of to avoid this is have a frame that covers the entire page.

Erwin

russpitre
Dec 5th, 2007, 02:03 PM
The browser will suspend all animation threads once the entire page is submitted. One trick I know of to avoid this is have a frame that covers the entire page.

Erwin

Another way to avoid this behavior is this:



<%@ include file="/WEB-INF/view/jsp/resources/includes/taglibs.jspf" %>
<%@ taglib prefix="project" tagdir="/WEB-INF/tags/project" %>
<head>
<title>Bid Packages Import Wizard ~ <c:out value="${project.name}"/></title>
<script language="javascript" type="text/javascript" src="${ctx}/resources/js/EventUtils.js"></script>
<script type="text/javascript">

function importSelected() {
window.status = 'Importing, please wait...';
var formObj = $('formImportbidPackageWizard');
formObj.submit();
window.setTimeout('updateImageSrc()', 50);
}

function updateImageSrc(){
var image = $('loadingGif');
image.style.display = '';
image.src = '${ctx}/resources/images/processing.gif';
}

addEvent(window, 'load', importSelected);
</script>
</head>
<project:editpageheader title="Bid Packages Import Wizard" project="${importBidPackagesWizardCommand.project}" printable="false" imageUrl="/resources/images/icons/large/bid_packages.gif" showMyActiveProjects="false" showSuggest="false"/>
<table width="99%" align="center">
<tr>
<td align="center">
<div align="center"><img src="${ctx}/resources/images/wizards/copy_bid_package/step_4.gif"></div>
</td>
</tr>
</table>
<springCustom:errors name="importBidPackagesWizardCommand"/>
<form:form commandName="importBidPackagesWizardCommand" cssClass="standard" name="formImportbidPackageWizard" id="formImportbidPackageWizard">
<input type="hidden" name="_eventId" value="import"/>
<div align="center" style="margin-top: 50px;">
<img src="${ctx}/resources/images/processing.gif" id="loadingGif" style="display: none;">
</div>
<c:forEach items="${selectedBidInvitationIds}" var="inviteId">
<input type="hidden" name="bidInvitationId" value="${inviteId}"/>
</c:forEach>
</form:form>



The importSelected() javascript function is attached the "load" event on the window object. When the browser is done loading and the dom is 100% accessible, that importSelected() function will submit the form and then "reload" the animated gif by setting the "src" attribute on the image element.


Help this helps.


Russ