Author: hlship Date: Thu Oct 6 15:38:49 2005 New Revision: 306946 URL: http://svn.apache.org/viewcvs?rev=306946&view=rev Log: Continue revving Virtual Library for Tapestry 4.0 Added: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.properties Removed: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Browser.jwc Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/ViewBook.html jakarta/tapestry/trunk/examples/Vlib/src/context/ViewPerson.html jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/BookLink.jwc jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.jwc jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.html jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.jwc jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/PersonLink.jwc jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.html jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.jwc jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/ViewBook.page jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/ViewPerson.page jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/BookLink.java jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Borrow.java jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Browser.java jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/ViewBook.html URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/ViewBook.html?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/ViewBook.html (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/ViewBook.html Thu Oct 6 15:38:49 2005 @@ -1,5 +1,5 @@ - + @@ -31,7 +31,7 @@ - + - + - + @@ -59,7 +59,7 @@ -
TitleDec 24 1966
Description @@ -41,7 +41,7 @@
Held By Howard Lewis Ship @@ -49,7 +49,7 @@
BorrowBorrow + Borrow
Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/ViewPerson.html URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/ViewPerson.html?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/ViewPerson.html (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/ViewPerson.html Thu Oct 6 15:38:49 2005 @@ -1,5 +1,5 @@ - + @@ -13,7 +13,7 @@
- + Jim Moran @@ -21,7 +21,7 @@ - + @@ -33,7 +33,7 @@ - @@ -41,7 +41,7 @@ -
Borrow
DocBook:The Definitive Guide + DocBook:The Definitive Guide Walsh & Muellner Jim Moran +
Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/BookLink.jwc URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/BookLink.jwc?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/BookLink.jwc (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/BookLink.jwc Thu Oct 6 15:38:49 2005 @@ -16,18 +16,14 @@ --> + "-//Apache Software Foundation//Tapestry Specification 4.0//EN" + "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> - - - + - - + + Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.jwc URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.jwc?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.jwc (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.jwc Thu Oct 6 15:38:49 2005 @@ -16,29 +16,20 @@ --> - - - - - + "-//Apache Software Foundation//Tapestry Specification 4.0//EN" + "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> + - - - + + + - - - - + + + - - - - - + + + Added: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.properties URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.properties?rev=306946&view=auto ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.properties (added) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Borrow.properties Thu Oct 6 15:38:49 2005 @@ -0,0 +1,15 @@ +# Copyright 2005 The Apache Software Foundation +# +# Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +borrowed-book=Borrowed: {0} \ No newline at end of file Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.html URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.html?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.html (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.html Thu Oct 6 15:38:49 2005 @@ -3,7 +3,7 @@
- Info + Info Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.jwc URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.jwc?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.jwc (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Information.jwc Thu Oct 6 15:38:49 2005 @@ -16,11 +16,6 @@ --> - - - - + "-//Apache Software Foundation//Tapestry Specification 4.0//EN" + "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> + Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/PersonLink.jwc URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/PersonLink.jwc?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/PersonLink.jwc (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/PersonLink.jwc Thu Oct 6 15:38:49 2005 @@ -16,22 +16,14 @@ --> - - - - - - - - - + "-//Apache Software Foundation//Tapestry Specification 4.0//EN" + "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> + + + + - - - - + + + Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.html URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.html?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.html (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.html Thu Oct 6 15:38:49 2005 @@ -3,7 +3,7 @@
- Question + Question Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.jwc URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.jwc?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.jwc (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/Question.jwc Thu Oct 6 15:38:49 2005 @@ -16,8 +16,8 @@ --> + "-//Apache Software Foundation//Tapestry Specification 4.0//EN" + "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> - - - - - - - - + "-//Apache Software Foundation//Tapestry Specification 4.0//EN" + "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> + - - + + - - - - + + - Modified: jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/ViewPerson.page URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/ViewPerson.page?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/ViewPerson.page (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/context/WEB-INF/ViewPerson.page Thu Oct 6 15:38:49 2005 @@ -16,54 +16,31 @@ --> - - - - - - - - - - - - - @org.apache.tapestry.vlib.ejb.SortColumn@TITLE - - - + "-//Apache Software Foundation//Tapestry Specification 4.0//EN" + "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd"> + + - - - - - - + + + + + - + - - + - - - - - - - "mailto:" + person.email - - + - - - - + + + + + + "mailto:" + person.email - Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/BookLink.java URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/BookLink.java?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/BookLink.java (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/BookLink.java Thu Oct 6 15:38:49 2005 @@ -17,7 +17,9 @@ import java.sql.Timestamp; import org.apache.tapestry.BaseComponent; -import org.apache.tapestry.IEngine; +import org.apache.tapestry.annotations.InjectState; +import org.apache.tapestry.annotations.InjectStateFlag; +import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.vlib.Visit; import org.apache.tapestry.vlib.ejb.Book; @@ -57,14 +59,21 @@ private static final long ONE_WEEK_MILLIS = 1000l * 60l * 60l * 24l * 7l; + @Parameter(required = true) + public abstract Book getBook(); + + @InjectState("visit") + public abstract Visit getVisitState(); + + @InjectStateFlag("visit") + public abstract boolean getVisitExists(); + public boolean isNewlyAdded() { - IEngine engine = getPage().getEngine(); - Visit visit = (Visit) engine.getVisit(); Timestamp lastAccess = null; - if (visit != null) - lastAccess = visit.getLastAccess(); + if (getVisitExists()) + lastAccess = getVisitState().getLastAccess(); Book book = getBook(); @@ -91,5 +100,4 @@ return lastAccess.compareTo(dateAdded) <= 0; } - public abstract Book getBook(); } Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Borrow.java URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Borrow.java?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Borrow.java (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Borrow.java Thu Oct 6 15:38:49 2005 @@ -20,7 +20,12 @@ import org.apache.hivemind.ApplicationRuntimeException; import org.apache.tapestry.BaseComponent; +import org.apache.tapestry.IPage; import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.annotations.InjectPage; +import org.apache.tapestry.annotations.InjectState; +import org.apache.tapestry.annotations.Message; +import org.apache.tapestry.annotations.Parameter; import org.apache.tapestry.vlib.VirtualLibraryEngine; import org.apache.tapestry.vlib.Visit; import org.apache.tapestry.vlib.ejb.Book; @@ -55,11 +60,21 @@ public abstract class Borrow extends BaseComponent { + @Parameter(required = true) public abstract Book getBook(); + @InjectState("visit") + public abstract Visit getVisit(); + + @InjectPage("Home") + public abstract Home getHome(); + + @Message + public abstract String borrowedBook(String title); + public boolean isLinkDisabled() { - Visit visit = (Visit) getPage().getVisit(); + Visit visit = getVisit(); if (!visit.isUserLoggedIn()) return true; @@ -79,13 +94,11 @@ return visit.isLoggedInUser(book.getHolderId()); } - public void borrow(IRequestCycle cycle) + public IPage borrow(IRequestCycle cycle, Integer bookPK) { - Object[] parameters = cycle.getServiceParameters(); - Integer bookPK = (Integer) parameters[0]; + Visit visit = getVisit(); + Home home = getHome(); - Visit visit = (Visit) getPage().getVisit(); - Home home = (Home) cycle.getPage("Home"); VirtualLibraryEngine vengine = (VirtualLibraryEngine) cycle.getEngine(); int i = 0; @@ -96,14 +109,14 @@ IOperations bean = vengine.getOperations(); Book book = bean.borrowBook(bookPK, visit.getUserId()); - home.setMessage("Borrowed: " + book.getTitle()); + home.setMessage(borrowedBook(book.getTitle())); break; } catch (BorrowException ex) { vengine.presentError(ex.getMessage(), cycle); - return; + return null; } catch (FinderException ex) { @@ -115,7 +128,7 @@ } } - cycle.activate(home); + return home; } } Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Browser.java URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Browser.java?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Browser.java (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/components/Browser.java Thu Oct 6 15:38:49 2005 @@ -22,22 +22,24 @@ import org.apache.tapestry.IPage; import org.apache.tapestry.IRequestCycle; import org.apache.tapestry.Tapestry; +import org.apache.tapestry.annotations.ComponentClass; +import org.apache.tapestry.annotations.Parameter; +import org.apache.tapestry.annotations.Persist; +import org.apache.tapestry.event.PageBeginRenderListener; import org.apache.tapestry.event.PageEvent; -import org.apache.tapestry.event.PageRenderListener; import org.apache.tapestry.vlib.VirtualLibraryEngine; import org.apache.tapestry.vlib.ejb.Book; import org.apache.tapestry.vlib.ejb.IBookQuery; /** * Implements a paging browser for the results of a {@link IBookQuery}. + * Renders its body multiple times, once for each book provided by the query. * * @author Howard Lewis Ship */ - -public abstract class Browser extends AbstractComponent implements PageRenderListener +@ComponentClass(allowInformalParameters = true, allowBody = true) +public abstract class Browser extends AbstractComponent implements PageBeginRenderListener { - public abstract IBookQuery getQuery(); - /** * Default for the page size; the number of results viewed on each page. */ @@ -50,22 +52,31 @@ private int _pageSize = DEFAULT_PAGE_SIZE; + @Parameter(required = true) + public abstract IBookQuery getQuery(); + + @Persist public abstract int getResultCount(); public abstract void setResultCount(int resultCount); + @Persist public abstract int getCurrentPage(); public abstract void setCurrentPage(int currentPage); public abstract void setElement(String element); + @Parameter public abstract String getElement(); + @Parameter(required = true) public abstract void setValue(Object value); + @Parameter(required = true) public abstract IActionListener getListener(); + @Persist public abstract Object[] getPageResults(); public abstract void setPageResults(Object[] pageResults); @@ -82,6 +93,7 @@ setPageCount(computePageCount()); } + @Persist public abstract int getPageCount(); public abstract void setPageCount(int pageCount); Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewBook.java Thu Oct 6 15:38:49 2005 @@ -21,8 +21,10 @@ import org.apache.tapestry.IExternalPage; import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.annotations.Meta; +import org.apache.tapestry.annotations.Persist; +import org.apache.tapestry.event.PageBeginRenderListener; import org.apache.tapestry.event.PageEvent; -import org.apache.tapestry.event.PageRenderListener; import org.apache.tapestry.html.BasePage; import org.apache.tapestry.vlib.VirtualLibraryEngine; import org.apache.tapestry.vlib.ejb.Book; @@ -33,11 +35,12 @@ * * @author Howard Lewis Ship */ - -public abstract class ViewBook extends BasePage implements IExternalPage, PageRenderListener +@Meta("page-type=Search") +public abstract class ViewBook extends BasePage implements IExternalPage, PageBeginRenderListener { private DateFormat _dateFormat; + @Persist public abstract Integer getBookId(); public abstract void setBookId(Integer bookId); Modified: jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java URL: http://svn.apache.org/viewcvs/jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java?rev=306946&r1=306945&r2=306946&view=diff ============================================================================== --- jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java (original) +++ jakarta/tapestry/trunk/examples/Vlib/src/java/org/apache/tapestry/vlib/pages/ViewPerson.java Thu Oct 6 15:38:49 2005 @@ -18,8 +18,11 @@ import org.apache.tapestry.IExternalPage; import org.apache.tapestry.IRequestCycle; +import org.apache.tapestry.annotations.InjectComponent; +import org.apache.tapestry.annotations.Meta; +import org.apache.tapestry.annotations.Persist; +import org.apache.tapestry.event.PageBeginRenderListener; import org.apache.tapestry.event.PageEvent; -import org.apache.tapestry.event.PageRenderListener; import org.apache.tapestry.html.BasePage; import org.apache.tapestry.vlib.VirtualLibraryEngine; import org.apache.tapestry.vlib.components.Browser; @@ -35,30 +38,37 @@ * * @author Howard Lewis Ship */ - -public abstract class ViewPerson extends BasePage implements IExternalPage, PageRenderListener +@Meta("page-type=Search") +public abstract class ViewPerson extends BasePage implements IExternalPage, PageBeginRenderListener { public abstract Integer getPersonId(); + @Persist public abstract void setPersonId(Integer personId); public abstract void setPerson(Person value); public abstract Person getPerson(); + @Persist public abstract IBookQuery getQuery(); public abstract void setQuery(IBookQuery value); + @Persist public abstract SortColumn getSortColumn(); + public abstract void setSortColumn(SortColumn sortColumn); + + @Persist public abstract boolean isDescending(); - private Browser _browser; + @InjectComponent("browser") + public abstract Browser getBrowser(); public void finishLoad() { - _browser = (Browser) getComponent("browser"); + setSortColumn(SortColumn.TITLE); } /** @@ -75,15 +85,15 @@ int count = runQuery(); - _browser.initializeForResultCount(count); + getBrowser().initializeForResultCount(count); } public void requery(IRequestCycle cycle) { int count = runQuery(); - if (_browser.getResultCount() != count) - _browser.setResultCount(count); + if (getBrowser().getResultCount() != count) + getBrowser().setResultCount(count); } private int runQuery() --------------------------------------------------------------------- To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org