You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2003/04/10 23:02:29 UTC
cvs commit: jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/components ColumnSorter.java Browser.java
hlship 2003/04/10 14:02:29
Modified: examples/Vlib/context/WEB-INF ViewBook.page Border.jwc
ViewPerson.page EditBook.page ColumnSorter.jwc
ColumnSorter.html ConfirmBookDelete.page
examples/Vlib/src/org/apache/tapestry/vlib/pages Login.java
MyLibrary.java BookMatches.java EditProfile.java
BorrowedBooks.java
examples/Vlib/src/org/apache/tapestry/vlib/components
ColumnSorter.java Browser.java
Added: examples/Vlib/src/org/apache/tapestry/vlib ActivatePage.java
Log:
More tweaks and improvements to the Virtual Library.
Revision Changes Path
1.8 +3 -1 jakarta-tapestry/examples/Vlib/context/WEB-INF/ViewBook.page
Index: ViewBook.page
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/ViewBook.page,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ViewBook.page 7 Apr 2003 18:16:54 -0000 1.7
+++ ViewBook.page 10 Apr 2003 21:02:28 -0000 1.8
@@ -6,6 +6,8 @@
<page-specification class="org.apache.tapestry.vlib.pages.ViewBook">
+ <property name="page-type" value="Search"/>
+
<property-specification name="bookId" type="java.lang.Integer" persistent="yes"/>
<property-specification name="book" type="org.apache.tapestry.vlib.ejb.Book"/>
1.10 +3 -1 jakarta-tapestry/examples/Vlib/context/WEB-INF/Border.jwc
Index: Border.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/Border.jwc,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Border.jwc 1 Apr 2003 17:00:28 -0000 1.9
+++ Border.jwc 10 Apr 2003 21:02:28 -0000 1.10
@@ -33,6 +33,7 @@
<component id="borrowedBooks" type="DirectLink">
<binding name="listener" expression="listeners.viewBorrowedBooks"/>
+ <binding name="stateful" expression="false"/>
</component>
<component id="borrowedBooksRollover" type="Rollover">
@@ -51,6 +52,7 @@
<component id="editProfile" type="DirectLink">
<binding name="listener" expression="listeners.editProfile"/>
+ <binding name="stateful" expression="false"/>
</component>
<component id="editProfileRollover" type="Rollover">
1.10 +3 -1 jakarta-tapestry/examples/Vlib/context/WEB-INF/ViewPerson.page
Index: ViewPerson.page
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/ViewPerson.page,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ViewPerson.page 7 Apr 2003 18:16:54 -0000 1.9
+++ ViewPerson.page 10 Apr 2003 21:02:28 -0000 1.10
@@ -6,6 +6,8 @@
<page-specification class="org.apache.tapestry.vlib.pages.ViewPerson">
+ <property name="page-type" value="Search"/>
+
<property-specification name="personId" type="java.lang.Integer" persistent="yes"/>
<property-specification name="person" type="org.apache.tapestry.vlib.ejb.Person"/>
1.8 +3 -1 jakarta-tapestry/examples/Vlib/context/WEB-INF/EditBook.page
Index: EditBook.page
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/EditBook.page,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- EditBook.page 2 Apr 2003 19:22:38 -0000 1.7
+++ EditBook.page 10 Apr 2003 21:02:28 -0000 1.8
@@ -5,6 +5,8 @@
"http://jakarta.apache.org/tapestry/dtd/Tapestry_1_4.dtd">
<page-specification class="org.apache.tapestry.vlib.pages.EditBook">
+
+ <property name="page-type" value="MyLibrary"/>
<property-specification name="error" type="java.lang.String"/>
<property-specification name="attributes" type="java.util.Map"/>
1.3 +2 -2 jakarta-tapestry/examples/Vlib/context/WEB-INF/ColumnSorter.jwc
Index: ColumnSorter.jwc
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/ColumnSorter.jwc,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ColumnSorter.jwc 8 Apr 2003 13:50:10 -0000 1.2
+++ ColumnSorter.jwc 10 Apr 2003 21:02:28 -0000 1.3
@@ -13,11 +13,11 @@
<parameter name="sortColumn" type="org.apache.tapestry.vlib.ejb.SortColumn" required="yes" direction="auto"/>
<parameter name="listener" type="org.apache.tapestry.IActionListener" required="yes" direction="auto"/>
- <component id="link1" type="DirectLink">
+ <component id="link" type="DirectLink">
<binding name="listener" expression="listeners.handleClick"/>
</component>
- <component id="link2" copy-of="link1"/>
+ <component id="iconLink" copy-of="link"/>
<component id="rollover" type="Rollover">
<binding name="image">
1.2 +4 -3 jakarta-tapestry/examples/Vlib/context/WEB-INF/ColumnSorter.html
Index: ColumnSorter.html
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/ColumnSorter.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ColumnSorter.html 1 Apr 2003 17:00:28 -0000 1.1
+++ ColumnSorter.html 10 Apr 2003 21:02:28 -0000 1.2
@@ -1,7 +1,8 @@
<!-- $Id$ -->
<span jwcid="$content$">
-<a jwcid="link1"><span jwcid="@RenderBody"/></a>
+<a jwcid="link"><span jwcid="@RenderBody"/></a>
<span jwcid="@Conditional" condition="ognl:sortColumn == selected">
-<a jwcid="link2"><img jwcid="rollover" width="17" height="16" alt="Resort Column"/></a>
+<a jwcid="iconLink"><img jwcid="rollover" width="17" height="16" alt="Resort Column"/></a>
+</span>
</span>
1.8 +2 -2 jakarta-tapestry/examples/Vlib/context/WEB-INF/ConfirmBookDelete.page
Index: ConfirmBookDelete.page
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/ConfirmBookDelete.page,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ConfirmBookDelete.page 2 Apr 2003 19:22:38 -0000 1.7
+++ ConfirmBookDelete.page 10 Apr 2003 21:02:28 -0000 1.8
@@ -6,7 +6,7 @@
<page-specification class="org.apache.tapestry.vlib.pages.ConfirmBookDelete">
- <property name="page-type">MyLibrary</property>
+ <property name="page-type" value="MyLibrary"/>
<property-specification name="bookId" type="java.lang.Integer"/>
<property-specification name="bookTitle" type="java.lang.String"/>
1.1 jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/ActivatePage.java
Index: ActivatePage.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation", "Tapestry"
* must not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* or "Tapestry", nor may "Apache" or "Tapestry" appear in their
* name, without prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE TAPESTRY CONTRIBUTOR COMMUNITY
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.tapestry.vlib;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.PageRedirectException;
import org.apache.tapestry.vlib.pages.Login;
/**
* Subclass of {@link org.apache.tapestry.vlib.Protected} that
* implements {@link org.apache.tapestry.vlib.IActivate}. Overrides
* {@link #validate(IRequestCycle)}.
*
* @author Howard Lewis Ship
* @version $Id: ActivatePage.java,v 1.1 2003/04/10 21:02:28 hlship Exp $
* @since 2.4
*
**/
public abstract class ActivatePage extends Protected implements IActivate
{
public void validate(IRequestCycle cycle)
{
Visit visit = (Visit) getVisit();
if (visit != null && visit.isUserLoggedIn())
return;
// User not logged in ... redirect through the Login page.
Login login = (Login) cycle.getPage("Login");
login.setCallback(new ActivateCallback(this));
throw new PageRedirectException(login);
}
}
1.8 +20 -16 jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/Login.java
Index: Login.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/Login.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Login.java 3 Apr 2003 23:47:19 -0000 1.7
+++ Login.java 10 Apr 2003 21:02:28 -0000 1.8
@@ -62,6 +62,8 @@
import org.apache.tapestry.IEngine;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.callback.ICallback;
+import org.apache.tapestry.event.PageEvent;
+import org.apache.tapestry.event.PageRenderListener;
import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.valid.IValidationDelegate;
@@ -84,7 +86,7 @@
*
**/
-public abstract class Login extends BasePage implements IErrorProperty
+public abstract class Login extends BasePage implements IErrorProperty, PageRenderListener
{
/**
* The name of a cookie to store on the user's machine that will identify
@@ -101,7 +103,7 @@
public abstract String getEmail();
public abstract String getPassword();
-
+
public abstract void setPassword(String password);
protected IValidationDelegate getValidationDelegate()
@@ -132,16 +134,16 @@
public void attemptLogin(IRequestCycle cycle)
{
- String password = getPassword();
-
- // Do a little extra work to clear out the password.
-
- setPassword(null);
- IValidationDelegate delegate = getValidationDelegate();
-
- delegate.setFormComponent((IFormComponent)getComponent("inputPassword"));
- delegate.recordFieldInputValue(null);
-
+ String password = getPassword();
+
+ // Do a little extra work to clear out the password.
+
+ setPassword(null);
+ IValidationDelegate delegate = getValidationDelegate();
+
+ delegate.setFormComponent((IFormComponent) getComponent("inputPassword"));
+ delegate.recordFieldInputValue(null);
+
// An error, from a validation field, may already have occured.
if (delegate.getHasErrors())
@@ -220,12 +222,14 @@
engine.forgetPage(getPageName());
}
- protected void prepareForRender(IRequestCycle cycle)
+ public void pageBeginRender(PageEvent event)
{
- super.prepareForRender(cycle);
-
if (getEmail() == null)
setEmail(getRequestCycle().getRequestContext().getCookieValue(COOKIE_NAME));
+ }
+
+ public void pageEndRender(PageEvent event)
+ {
}
}
1.10 +5 -19 jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/MyLibrary.java
Index: MyLibrary.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/MyLibrary.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MyLibrary.java 7 Apr 2003 18:16:54 -0000 1.9
+++ MyLibrary.java 10 Apr 2003 21:02:28 -0000 1.10
@@ -63,9 +63,11 @@
import org.apache.tapestry.PageRedirectException;
import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.vlib.ActivateCallback;
+import org.apache.tapestry.vlib.ActivatePage;
import org.apache.tapestry.vlib.IActivate;
import org.apache.tapestry.vlib.IErrorProperty;
import org.apache.tapestry.vlib.IMessageProperty;
+import org.apache.tapestry.vlib.Protected;
import org.apache.tapestry.vlib.VirtualLibraryEngine;
import org.apache.tapestry.vlib.Visit;
import org.apache.tapestry.vlib.components.Browser;
@@ -91,8 +93,8 @@
**/
public abstract class MyLibrary
- extends BasePage
- implements IMessageProperty, IActivate, IErrorProperty
+ extends ActivatePage
+ implements IMessageProperty
{
public abstract void setOwnedQuery(IBookQuery value);
@@ -107,22 +109,6 @@
public void finishLoad()
{
_browser = (Browser) getComponent("browser");
- }
-
- public void validate(IRequestCycle cycle)
- {
- Visit visit = (Visit) getVisit();
-
- if (visit != null && visit.isUserLoggedIn())
- return;
-
- // User not logged in ... redirect through the Login page.
-
- Login login = (Login) cycle.getPage("Login");
-
- login.setCallback(new ActivateCallback(this));
-
- throw new PageRedirectException(login);
}
public void activate(IRequestCycle cycle)
1.7 +12 -13 jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/BookMatches.java
Index: BookMatches.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/BookMatches.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BookMatches.java 7 Apr 2003 18:16:54 -0000 1.6
+++ BookMatches.java 10 Apr 2003 21:02:28 -0000 1.7
@@ -57,15 +57,15 @@
import java.rmi.RemoteException;
-import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.html.BasePage;
-import org.apache.tapestry.vlib.IErrorProperty;
-import org.apache.tapestry.vlib.VirtualLibraryEngine;
-import org.apache.tapestry.vlib.components.Browser;
-import org.apache.tapestry.vlib.ejb.IBookQuery;
-import org.apache.tapestry.vlib.ejb.MasterQueryParameters;
-import org.apache.tapestry.vlib.ejb.SortColumn;
-import org.apache.tapestry.vlib.ejb.SortOrdering;
+ import org.apache.tapestry.IRequestCycle;
+ import org.apache.tapestry.html.BasePage;
+ import org.apache.tapestry.vlib.IMessageProperty;
+ import org.apache.tapestry.vlib.VirtualLibraryEngine;
+ import org.apache.tapestry.vlib.components.Browser;
+ import org.apache.tapestry.vlib.ejb.IBookQuery;
+ import org.apache.tapestry.vlib.ejb.MasterQueryParameters;
+ import org.apache.tapestry.vlib.ejb.SortColumn;
+ import org.apache.tapestry.vlib.ejb.SortOrdering;
/**
* Runs queries and displays matches.
@@ -108,9 +108,8 @@
if (count == 0)
{
- Home home = (Home) cycle.getPage("Home");
- home.setMessage(getString("no-matches"));
- cycle.setPage(home);
+ IMessageProperty page = (IMessageProperty) cycle.getPage();
+ page.setMessage(getString("no-matches"));
return;
}
1.9 +6 -7 jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/EditProfile.java
Index: EditProfile.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/EditProfile.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- EditProfile.java 3 Apr 2003 23:47:19 -0000 1.8
+++ EditProfile.java 10 Apr 2003 21:02:28 -0000 1.9
@@ -68,8 +68,7 @@
import org.apache.tapestry.event.PageRenderListener;
import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.valid.IValidationDelegate;
-import org.apache.tapestry.vlib.IActivate;
-import org.apache.tapestry.vlib.Protected;
+import org.apache.tapestry.vlib.ActivatePage;
import org.apache.tapestry.vlib.VirtualLibraryEngine;
import org.apache.tapestry.vlib.Visit;
import org.apache.tapestry.vlib.ejb.IOperations;
@@ -82,7 +81,7 @@
*
**/
-public abstract class EditProfile extends Protected implements PageRenderListener, IActivate
+public abstract class EditProfile extends ActivatePage implements PageRenderListener
{
public abstract String getPassword1();
@@ -109,7 +108,7 @@
public void activate(IRequestCycle cycle)
{
Visit visit = (Visit) getVisit();
- VirtualLibraryEngine vengine = (VirtualLibraryEngine)cycle.getEngine();
+ VirtualLibraryEngine vengine = (VirtualLibraryEngine) cycle.getEngine();
Integer userId = visit.getUserId();
Map attributes = null;
@@ -181,7 +180,7 @@
}
Visit visit = (Visit) getVisit();
- VirtualLibraryEngine vengine = (VirtualLibraryEngine)cycle.getEngine();
+ VirtualLibraryEngine vengine = (VirtualLibraryEngine) cycle.getEngine();
Integer userId = visit.getUserId();
int i = 0;
@@ -213,7 +212,7 @@
vengine.clearCache();
- MyLibrary myLibrary = (MyLibrary)cycle.getPage("MyLibrary");
+ MyLibrary myLibrary = (MyLibrary) cycle.getPage("MyLibrary");
myLibrary.activate(cycle);
}
1.9 +4 -5 jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/BorrowedBooks.java
Index: BorrowedBooks.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/BorrowedBooks.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- BorrowedBooks.java 7 Apr 2003 18:16:54 -0000 1.8
+++ BorrowedBooks.java 10 Apr 2003 21:02:28 -0000 1.9
@@ -61,9 +61,8 @@
import org.apache.tapestry.ApplicationRuntimeException;
import org.apache.tapestry.IRequestCycle;
-import org.apache.tapestry.vlib.IActivate;
+import org.apache.tapestry.vlib.ActivatePage;
import org.apache.tapestry.vlib.IMessageProperty;
-import org.apache.tapestry.vlib.Protected;
import org.apache.tapestry.vlib.VirtualLibraryEngine;
import org.apache.tapestry.vlib.Visit;
import org.apache.tapestry.vlib.components.Browser;
@@ -82,8 +81,8 @@
**/
public abstract class BorrowedBooks
- extends Protected
- implements IMessageProperty, IActivate
+ extends ActivatePage
+ implements IMessageProperty
{
private Browser _browser;
1.3 +1 -12 jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/components/ColumnSorter.java
Index: ColumnSorter.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/components/ColumnSorter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ColumnSorter.java 2 Apr 2003 19:22:43 -0000 1.2
+++ ColumnSorter.java 10 Apr 2003 21:02:28 -0000 1.3
@@ -105,15 +105,4 @@
listener.actionTriggered(this, cycle);
}
-
- public IAsset getImage()
- {
- return getAsset(isDescending() ? "up" : "down");
-
- }
-
- public IAsset getFocus()
- {
- return getAsset(isDescending() ? "up_h" : "down_h");
- }
}
1.6 +13 -7 jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/components/Browser.java
Index: Browser.java
===================================================================
RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/components/Browser.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Browser.java 7 Apr 2003 18:16:55 -0000 1.5
+++ Browser.java 10 Apr 2003 21:02:29 -0000 1.6
@@ -155,6 +155,15 @@
return result;
}
+ /**
+ * Invoked to change the displayed page number.
+ *
+ * @param page page to display, numbered from one. The currentPage property will be
+ * updated. The value is constrained to fit in the valid range of pages
+ * for the component.
+ *
+ **/
+
public void jump(int page)
{
if (page < 2)
@@ -198,14 +207,12 @@
{
Object[] books = getPageResults();
int count = Tapestry.size(books);
-
+ String element = getElement();
+
for (int i = 0; i < count; i++)
{
-
setValue(books[i]);
- String element = getElement();
-
if (element != null)
{
writer.begin(element);
@@ -236,8 +243,8 @@
return;
Book[] pageResults = null;
+
int i = 0;
-
while (true)
{
@@ -267,7 +274,6 @@
public void pageEndRender(PageEvent event)
{
- setPageResults(null);
}
}