|
From: <max...@us...> - 2009-09-24 14:59:42
|
Revision: 3874
http://uni-d.svn.sourceforge.net/uni-d/?rev=3874&view=rev
Author: max_brod
Date: 2009-09-24 14:59:15 +0000 (Thu, 24 Sep 2009)
Log Message:
-----------
New page, to show progress of a long-working page in a popup.
Modified Paths:
--------------
trunk/Uni-d/tapestry/src/main/resources/Uni-d-tapestry.library
Added Paths:
-----------
trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/progressInfo/
trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.java
trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/pages/progressInfo/
trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.html
Added: trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.java
===================================================================
--- trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.java (rev 0)
+++ trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.java 2009-09-24 14:59:15 UTC (rev 3874)
@@ -0,0 +1,107 @@
+/**
+ * This file is part of the Uni-d project.
+ * $Id$
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+package be.unid.tapestry.pages.progressInfo;
+
+import be.unid.tapestry.pages.actionResult.ActionResultPageParams;
+import be.unid.tapestry.navigation.NavigationablePageImpl;
+import be.unid.tapestry.util.UnidFormValidator;
+import org.apache.tapestry.event.PageBeginRenderListener;
+import org.apache.tapestry.event.PageEvent;
+import org.apache.tapestry.annotations.Bean;
+import org.apache.tapestry.valid.ValidationDelegate;
+import org.apache.log4j.Logger;
+
+import javax.servlet.http.HttpSession;
+
+/**
+ * A page to be used like a popup, to give some progress info, while something is running
+ * in the background
+ *
+ * @author Florin
+ * @version $Revision$
+ */
+public abstract class ProgressInfoPage
+ extends NavigationablePageImpl
+ implements PageBeginRenderListener
+{
+ private static final Logger log = Logger.getLogger( ProgressInfoPage.class );
+
+ public static final java.lang.String ACTION_STATUS_NAME_PREFIX = "action_status";
+ public static final java.lang.String ACTION_INFO_NAME_PREFIX = "action_info";
+ public static final java.lang.String ACTION_STATUS_WORKING = "working";
+ public static final java.lang.String ACTION_STATUS_DONE = "done";
+
+ @Bean( UnidFormValidator.class )
+ public abstract ValidationDelegate getValidationDelegate();
+
+ public abstract String getActionId();
+
+ public abstract void setActionId( String actionId );
+
+ public abstract boolean isActionFinished();
+
+ public abstract void setActionFinished( boolean finished );
+
+ public abstract String getActionInfo();
+
+ public abstract void setActionInfo( String info );
+
+ public void pageBeginRender( PageEvent pageEvent )
+ {
+ String actionId = getRequestCycle().getParameter( "actionId" );
+ if ( actionId != null )
+ {
+ setActionId( actionId );
+ }
+ super.pageBeginRender(
+ pageEvent ); //To change body of overridden methods use File | Settings | File Templates.
+ }
+
+ public void restart()
+ {
+ HttpSession session = getHttpServletRequest().getSession();
+
+ String actionStatusName = ACTION_STATUS_NAME_PREFIX + getActionId();
+ String actionInfoName = ACTION_INFO_NAME_PREFIX + getActionId();
+
+ if ( session.getAttribute( actionStatusName ) == null )
+ {
+ setActionFinished( true );
+ log.error( "Internal error: session.getAttribute(" + actionStatusName + ")==null" );
+ }
+ else
+ {
+ if ( ( session.getAttribute( actionStatusName ) ).equals( ACTION_STATUS_WORKING ) )
+ {
+ setActionInfo( (String) session.getAttribute( actionInfoName ) );
+ }
+ else if ( ( session.getAttribute( actionStatusName ) ).equals( ACTION_STATUS_DONE ) )
+ {
+ setActionFinished( true );
+ }
+
+ }
+ }
+}
Property changes on: trunk/Uni-d/tapestry/src/main/java/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/Uni-d/tapestry/src/main/resources/Uni-d-tapestry.library
===================================================================
--- trunk/Uni-d/tapestry/src/main/resources/Uni-d-tapestry.library 2009-08-31 07:05:30 UTC (rev 3873)
+++ trunk/Uni-d/tapestry/src/main/resources/Uni-d-tapestry.library 2009-09-24 14:59:15 UTC (rev 3874)
@@ -33,6 +33,7 @@
be.unid.tapestry.pages.tableManager,
be.unid.tapestry.pages.tablesIndex,
be.unid.tapestry.pages.tablesCategoryIndex,
+ be.unid.tapestry.pages.progressInfo,
be.unid.tapestry.pages.reportsCategoryIndex,
be.unid.tapestry.pages.view,
be.unid.tapestry.pages.userAdmin.adminMenu,
Added: trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.html
===================================================================
--- trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.html (rev 0)
+++ trunk/Uni-d/tapestry/src/main/resources/be/unid/tapestry/pages/progressInfo/ProgressInfoPage.html 2009-09-24 14:59:15 UTC (rev 3874)
@@ -0,0 +1,71 @@
+<span jwcid="$remove$">
+This file is part of the Uni-d project.
+$Id: ActionResultPage.html 3444 2007-05-11 13:51:31Z pushkutza $
+
+The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at http://www.mozilla.org/MPL/
+
+Code generated by applying this template can be freely used.
+
+Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ANY KIND, either express or implied. See the License for the specific language governing rights and
+limitations under the License.
+
+Alternatively, the contents of this file may be used under the terms of
+either the GNU General Public License Version 2 or later (the "GPL"), or
+the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+in which case the provisions of the GPL or the LGPL are applicable instead
+of those above. If you wish to allow use of your version of this file only
+under the terms of either the GPL or the LGPL, and not to allow others to
+use your version of this file under the terms of the MPL, indicate your
+decision by deleting the provisions above and replace them with the notice
+and other provisions required by the GPL or the LGPL. If you do not delete
+the provisions above, a recipient may use your version of this file under
+the terms of any one of the MPL, the GPL or the LGPL.
+
+A page to be used like a popup, to give some progress info, while something is running
+ in the background
+
+Contributor(s):
+@author Florin
+
+@version $Revision: 3444 $
+</span>
+
+<html>
+<script>
+ window.onload = function()
+ {
+ var actionFinished = document.getElementById("ACTION_FINISHED");
+ if ( actionFinished.checked )
+ {
+ window.close();
+ }
+ else
+ {
+ setTimeout("go_now()", 1000);
+ }
+ }
+
+ function go_now()
+ {
+ document.getElementById("BUTTON_SUBMIT").click();
+ }
+</script>
+
+<body jwcid="@Body">
+<span jwcid="keepAlive"/>
+
+<center>
+ <form jwcid="@Form" delegate="bean:validationDelegate" enctype="multipart/form-data">
+ <span jwcid="ACTION_ID@TextField" value="prop:actionId" style="display:none"/>
+ <span jwcid="ACTION_FINISHED@Checkbox" value="prop:actionFinished" style="display:none"/>
+ <span jwcid="@Insert" value="prop:actionInfo" raw="true"/>
+ <span jwcid="BUTTON_SUBMIT@Submit" style="display:none" action="listener:restart"/>
+ </form>
+</center>
+
+
+</body>
+</html>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|