tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/components Browser.java
Date Mon, 07 Apr 2003 18:16:55 GMT
hlship      2003/04/07 11:16:55

  Modified:    examples/VlibBeans/src/org/apache/tapestry/vlib/ejb/impl
                        OperationsBean.java
               examples/wap/context/WEB-INF web.xml
               examples/Vlib/src/org/apache/tapestry/vlib/pages
                        ViewPerson.java ViewBook.java MyLibrary.java
                        BookMatches.java BorrowedBooks.java
               examples/Vlib/src/org/apache/tapestry/vlib/pages/admin
                        EditUsers.java
               examples/Vlib/context/WEB-INF BookMatches.page Browser.jwc
                        MyLibrary.page ViewPerson.page BorrowedBooks.page
                        ViewBook.page
               examples/Vlib/context BorrowedBooks.html Home.html
                        BookMatches.html ViewPerson.html MyLibrary.html
               examples/Vlib/src/org/apache/tapestry/vlib Global.java
                        VirtualLibraryEngine.java Visit.java
               examples/Vlib/src/org/apache/tapestry/vlib/components
                        Browser.java
  Log:
  Improve robustness of applicaiton, even when app server restarts.
  
  Revision  Changes    Path
  1.4       +31 -4     jakarta-tapestry/examples/VlibBeans/src/org/apache/tapestry/vlib/ejb/impl/OperationsBean.java
  
  Index: OperationsBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/VlibBeans/src/org/apache/tapestry/vlib/ejb/impl/OperationsBean.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- OperationsBean.java	2 Apr 2003 19:22:36 -0000	1.3
  +++ OperationsBean.java	7 Apr 2003 18:16:54 -0000	1.4
  @@ -720,15 +720,37 @@
           }
   
           count = Tapestry.size(deleted);
  -        
  +
           if (count > 0)
  +        {
  +            returnBooksFromDeletedPersons(deleted);
               moveBooksFromDeletedPersons(deleted, adminId);
  +        }
   
           for (int i = 0; i < count; i++)
               home.remove(deleted[i]);
       }
   
       /**
  +     *  Invoked to update all books owned by people about to be deleted, to 
  +     *  reassign the books holder back to the owner.
  +     * 
  +     **/
  +
  +    private void returnBooksFromDeletedPersons(Integer deletedPersonIds[]) throws RemoveException
  +    {
  +        StatementAssembly assembly = new StatementAssembly();
  +
  +        assembly.add("UPDATE BOOK");
  +        assembly.newLine("SET HOLDER_ID = OWNER_ID");
  +        assembly.newLine("WHERE HOLDER_ID IN (");
  +        assembly.addParameterList(deletedPersonIds, ", ");
  +        assembly.add(")");
  +
  +        executeUpdate(assembly);
  +    }
  +
  +    /**
        *  Invoked to execute a bulk update that moves books to the new admin.
        *
        **/
  @@ -745,6 +767,12 @@
           assembly.addParameterList(deletedPersonIds, ", ");
           assembly.add(")");
   
  +        executeUpdate(assembly);
  +
  +    }
  +
  +    private void executeUpdate(StatementAssembly assembly) throws XRemoveException
  +    {
           Connection connection = null;
           IStatement statement = null;
   
  @@ -765,14 +793,13 @@
           catch (SQLException ex)
           {
               throw new XRemoveException(
  -                "Unable to move books from deleted owners: " + ex.getMessage(),
  +                "Unable to execute " + assembly + ": " + ex.getMessage(),
                   ex);
           }
           finally
           {
               close(connection, statement, null);
           }
  -
       }
   
       /**
  
  
  
  1.2       +3 -1      jakarta-tapestry/examples/wap/context/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/wap/context/WEB-INF/web.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- web.xml	25 Mar 2003 04:37:55 -0000	1.1
  +++ web.xml	7 Apr 2003 18:16:54 -0000	1.2
  @@ -3,7 +3,9 @@
   <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
    "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
   <web-app>
  +  
   	<display-name>Tapestry WAP Examples</display-name>
  +	 
   	<servlet>
   		<servlet-name>hello</servlet-name>
           <servlet-class>org.apache.tapestry.ApplicationServlet</servlet-class>
  
  
  
  1.7       +31 -12    jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/ViewPerson.java
  
  Index: ViewPerson.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/ViewPerson.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ViewPerson.java	3 Apr 2003 23:47:19 -0000	1.6
  +++ ViewPerson.java	7 Apr 2003 18:16:54 -0000	1.7
  @@ -59,6 +59,8 @@
   
   import org.apache.tapestry.IExternalPage;
   import org.apache.tapestry.IRequestCycle;
  +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;
  @@ -77,8 +79,12 @@
    * 
    **/
   
  -public abstract class ViewPerson extends BasePage implements IExternalPage
  +public abstract class ViewPerson extends BasePage implements IExternalPage, PageRenderListener
   {
  +    public abstract Integer getPersonId();
  +
  +    public abstract void setPersonId(Integer personId);
  +
       public abstract void setPerson(Person value);
   
       public abstract Person getPerson();
  @@ -106,20 +112,16 @@
   
       public void activateExternalPage(Object[] parameters, IRequestCycle cycle)
       {
  -        Integer personPK = (Integer) parameters[0];
  -
  -        VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();
  +        Integer personId = (Integer) parameters[0];
   
  -        Person person = vengine.readPerson(personPK);
  +        setPersonId(personId);
   
  -        setPerson(person);
  +        // Force the query to be re-run when the person changes.
   
           runQuery();
  -
  -        // cycle.setPage(this);
       }
   
  -    public void resort(IRequestCycle cycle)
  +    public void requery(IRequestCycle cycle)
       {
           runQuery();
       }
  @@ -127,7 +129,7 @@
       private void runQuery()
       {
           VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();
  -        Person person = getPerson();
  +        Integer personId = getPersonId();
   
           SortOrdering ordering = new SortOrdering(getSortColumn(), isDescending());
   
  @@ -145,7 +147,7 @@
   
               try
               {
  -                int count = query.ownerQuery(person.getId(), ordering);
  +                int count = query.ownerQuery(personId, ordering);
   
                   _browser.initializeForResultCount(count);
   
  @@ -161,4 +163,21 @@
   
       }
   
  +    public void pageBeginRender(PageEvent event)
  +    {
  +        Person person = getPerson();
  +
  +        if (person == null)
  +        {
  +            VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();
  +
  +            person = vengine.readPerson(getPersonId());
  +
  +            setPerson(person);
  +        }
  +    }
  +
  +	public void pageEndRender(PageEvent event)
  +	{
  +	}
   }
  
  
  
  1.4       +31 -6     jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/ViewBook.java
  
  Index: ViewBook.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/ViewBook.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ViewBook.java	31 Mar 2003 21:50:05 -0000	1.3
  +++ ViewBook.java	7 Apr 2003 18:16:54 -0000	1.4
  @@ -62,6 +62,8 @@
   
   import org.apache.tapestry.IExternalPage;
   import org.apache.tapestry.IRequestCycle;
  +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;
  @@ -75,18 +77,29 @@
    * 
    **/
   
  -public abstract class ViewBook extends BasePage implements IExternalPage
  +public abstract class ViewBook extends BasePage implements IExternalPage, PageRenderListener
   {
       private DateFormat _dateFormat;
   
  +    public abstract Integer getBookId();
  +
  +    public abstract void setBookId(Integer bookId);
  +
       public abstract Book getBook();
   
       public abstract void setBook(Book value);
   
       public void activateExternalPage(Object[] parameters, IRequestCycle cycle)
       {
  -        Integer bookPK = (Integer) parameters[0];
  +        Integer bookId = (Integer) parameters[0];
  +
  +        setBookId(bookId);
  +    }
  +
  +    public void readBook()
  +    {
           VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();
  +        Integer bookId = getBookId();
   
           int i = 0;
           while (true)
  @@ -95,19 +108,19 @@
   
               try
               {
  -                setBook(bean.getBook(bookPK));
  +                setBook(bean.getBook(bookId));
   
                   return;
               }
               catch (FinderException ex)
               {
  -                vengine.presentError("Book not found in database.", cycle);
  +                vengine.presentError("Book not found in database.", getRequestCycle());
                   return;
               }
               catch (RemoteException ex)
               {
                   vengine.rmiFailure(
  -                    "Remote exception obtaining information for book " + bookPK + ".",
  +                    "Remote exception obtaining information for book #" + bookId + ".",
                       ex,
                       i++);
               }
  @@ -123,4 +136,16 @@
   
           return _dateFormat;
       }
  +
  +    public void pageBeginRender(PageEvent event)
  +    {
  +        if (getBook() == null)
  +            readBook();
  +    }
  +
  +    public void pageEndRender(PageEvent event)
  +    {
  +
  +    }
  +
   }
  
  
  
  1.9       +2 -2      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MyLibrary.java	2 Apr 2003 19:22:43 -0000	1.8
  +++ MyLibrary.java	7 Apr 2003 18:16:54 -0000	1.9
  @@ -132,7 +132,7 @@
           cycle.setPage(this);
       }
   
  -    public void resort(IRequestCycle cycle)
  +    public void requery(IRequestCycle cycle)
       {
           runQuery();
       }
  
  
  
  1.6       +16 -27    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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BookMatches.java	2 Apr 2003 19:22:42 -0000	1.5
  +++ BookMatches.java	7 Apr 2003 18:16:54 -0000	1.6
  @@ -104,7 +104,7 @@
       {
           setQueryParameters(parameters);
   
  -        int count = executeQuery(cycle);
  +        int count = executeQuery();
   
           if (count == 0)
           {
  @@ -118,26 +118,18 @@
           cycle.setPage(this);
       }
   
  -    public void resort(IRequestCycle cycle)
  +    public void requery(IRequestCycle cycle)
       {
  -        int count = executeQuery(cycle);
  +        int count = executeQuery();
   
           if (count != _browser.getResultCount())
               _browser.initializeForResultCount(count);
       }
   
  -    private int executeQuery(IRequestCycle cycle)
  +    private int executeQuery()
       {
           VirtualLibraryEngine vengine = (VirtualLibraryEngine) getEngine();
   
  -        IBookQuery query = getBookQuery();
  -
  -        if (query == null)
  -        {
  -            query = vengine.createNewQuery();
  -            setBookQuery(query);
  -        }
  -
           MasterQueryParameters parameters = getQueryParameters();
   
           SortOrdering ordering = new SortOrdering(getSortColumn(), isDescending());
  @@ -145,26 +137,23 @@
           int i = 0;
           while (true)
           {
  -
               try
               {
  +                IBookQuery query = getBookQuery();
  +
  +                if (query == null)
  +                {
  +                    query = vengine.createNewQuery();
  +                    setBookQuery(query);
  +                }
  +                
                   return query.masterQuery(parameters, ordering);
               }
               catch (RemoteException ex)
               {
  -                String message = "Remote exception processing query.";
  -
  -                vengine.rmiFailure(message, ex, 0);
  -
  -                if (i++ > 0)
  -                {
  -                    // This method is invoked from the Home page.  We return
  -                    // without changing the response page.
  -
  -                    IErrorProperty page = (IErrorProperty) cycle.getPage();
  -                    page.setError(message);
  -                    return 0;
  -                }
  +                vengine.rmiFailure("Remote exception processing query.", ex, i++);
  +                
  +                setBookQuery(null);
               }
   
           }
  
  
  
  1.8       +2 -2      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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BorrowedBooks.java	2 Apr 2003 19:22:42 -0000	1.7
  +++ BorrowedBooks.java	7 Apr 2003 18:16:54 -0000	1.8
  @@ -117,7 +117,7 @@
   	 *
   	 **/
   	
  -    public void resort(IRequestCycle cycle)
  +    public void requery(IRequestCycle cycle)
       {
           runQuery();
       }
  
  
  
  1.7       +4 -1      jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/admin/EditUsers.java
  
  Index: EditUsers.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/pages/admin/EditUsers.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EditUsers.java	3 Apr 2003 23:47:19 -0000	1.6
  +++ EditUsers.java	7 Apr 2003 18:16:54 -0000	1.7
  @@ -222,6 +222,9 @@
               }
           }
   
  +		// Force a requery
  +		
  +		setListEditMap(null);
           setMessage(getString("users-updated"));
   
       }
  
  
  
  1.6       +17 -7     jakarta-tapestry/examples/Vlib/context/WEB-INF/BookMatches.page
  
  Index: BookMatches.page
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/BookMatches.page,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BookMatches.page	2 Apr 2003 19:22:38 -0000	1.5
  +++ BookMatches.page	7 Apr 2003 18:16:54 -0000	1.6
  @@ -22,25 +22,35 @@
      
     <component id="sortTitle" type="ColumnSorter">
       <binding name="selected" expression="sortColumn"/>
  -    <binding name="sortColumn" expression="@org.apache.tapestry.vlib.ejb.SortColumn@TITLE"/>
  +    <binding name="sortColumn">
  +      @org.apache.tapestry.vlib.ejb.SortColumn@TITLE
  +    </binding> 
       <binding name="descending" expression="descending"/>
  -    <binding name="listener" expression="listeners.resort"/>
  +    <binding name="listener" expression="listeners.requery"/>
     </component> 
     
     <component id="sortAuthor" copy-of="sortTitle">
  -    <binding name="sortColumn" expression="@org.apache.tapestry.vlib.ejb.SortColumn@AUTHOR"/>
  +    <binding name="sortColumn">
  +      @org.apache.tapestry.vlib.ejb.SortColumn@AUTHOR
  +    </binding>
     </component>
     
     <component id="sortPublisher" copy-of="sortTitle">
  -    <binding name="sortColumn" expression="@org.apache.tapestry.vlib.ejb.SortColumn@PUBLISHER"/>

  +    <binding name="sortColumn">
  +    	@org.apache.tapestry.vlib.ejb.SortColumn@PUBLISHER
  +    </binding>	
     </component>
     
     <component id="sortOwner" copy-of="sortTitle">
  -    <binding name="sortColumn" expression="@org.apache.tapestry.vlib.ejb.SortColumn@OWNER"/>
  +    <binding name="sortColumn">
  +    	@org.apache.tapestry.vlib.ejb.SortColumn@OWNER
  +    </binding>
     </component>
    
     <component id="sortBorrower" copy-of="sortTitle">
  -    <binding name="sortColumn" expression="@org.apache.tapestry.vlib.ejb.SortColumn@HOLDER"/>
  +    <binding name="sortColumn">
  +    	@org.apache.tapestry.vlib.ejb.SortColumn@HOLDER
  +    </binding>
     </component>
     
     <component id="ownerLink" type="PersonLink">
  
  
  
  1.9       +5 -2      jakarta-tapestry/examples/Vlib/context/WEB-INF/Browser.jwc
  
  Index: Browser.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/Browser.jwc,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Browser.jwc	2 Apr 2003 19:22:38 -0000	1.8
  +++ Browser.jwc	7 Apr 2003 18:16:54 -0000	1.9
  @@ -8,15 +8,18 @@
   	allow-informal-parameters="yes" 
   	class="org.apache.tapestry.vlib.components.Browser">
   
  -  <parameter name="query" required="yes" type="org.apache.tapestry.vlib.ejb.IBookQuery"
direction="in"/>
  +  <parameter name="query" required="yes" type="org.apache.tapestry.vlib.ejb.IBookQuery"
direction="auto"/>
     
     <parameter name="value" type="java.lang.Object" required="yes" direction="auto"/>
     
     <parameter name="element" type="java.lang.String" direction="in"/>
     
  +  <parameter name="listener" type="org.apache.tapestry.IActionListener" required="yes"
direction="auto"/>
  +  
     <property-specification name="resultCount" type="int" persistent="yes"/>
     <property-specification name="currentPage" type="int" persistent="yes"/>
     <property-specification name="pageCount" type="int" persistent="yes"/>
  +  <property-specification name="pageResults" type="java.lang.Object[]"/>
    
   </component-specification>
   
  
  
  
  1.10      +2 -2      jakarta-tapestry/examples/Vlib/context/WEB-INF/MyLibrary.page
  
  Index: MyLibrary.page
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/MyLibrary.page,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MyLibrary.page	2 Apr 2003 19:22:38 -0000	1.9
  +++ MyLibrary.page	7 Apr 2003 18:16:54 -0000	1.10
  @@ -20,7 +20,7 @@
       <binding name="selected" expression="sortColumn"/>
       <binding name="sortColumn" expression="@org.apache.tapestry.vlib.ejb.SortColumn@TITLE"/>
       <binding name="descending" expression="descending"/>
  -    <binding name="listener" expression="listeners.resort"/>
  +    <binding name="listener" expression="listeners.requery"/>
     </component>   
       
     <component id="sortAuthor" copy-of="sortTitle">
  
  
  
  1.9       +5 -5      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ViewPerson.page	2 Apr 2003 19:22:38 -0000	1.8
  +++ ViewPerson.page	7 Apr 2003 18:16:54 -0000	1.9
  @@ -6,10 +6,10 @@
   	
   <page-specification class="org.apache.tapestry.vlib.pages.ViewPerson">
   
  -  <property name="page-type">search</property>
  - 
  +  <property-specification name="personId" type="java.lang.Integer" persistent="yes"/>
  +  <property-specification name="person" type="org.apache.tapestry.vlib.ejb.Person"/>
  +  
     <property-specification name="query" type="org.apache.tapestry.vlib.ejb.IBookQuery"
persistent="yes"/>
  -  <property-specification name="person" type="org.apache.tapestry.vlib.ejb.Person" persistent="yes"/>
     <property-specification name="currentMatch" type="org.apache.tapestry.vlib.ejb.Book"/>
   
     <property-specification name="sortColumn" type="org.apache.tapestry.vlib.ejb.SortColumn"
persistent="yes">
  @@ -21,7 +21,7 @@
       <binding name="selected" expression="sortColumn"/>
       <binding name="sortColumn" expression="@org.apache.tapestry.vlib.ejb.SortColumn@TITLE"/>
       <binding name="descending" expression="descending"/>
  -    <binding name="listener" expression="listeners.resort"/>
  +    <binding name="listener" expression="listeners.requery"/>
     </component>   
       
     <component id="sortAuthor" copy-of="sortTitle">
  
  
  
  1.9       +2 -2      jakarta-tapestry/examples/Vlib/context/WEB-INF/BorrowedBooks.page
  
  Index: BorrowedBooks.page
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/WEB-INF/BorrowedBooks.page,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BorrowedBooks.page	1 Apr 2003 17:00:29 -0000	1.8
  +++ BorrowedBooks.page	7 Apr 2003 18:16:54 -0000	1.9
  @@ -20,7 +20,7 @@
       <binding name="selected" expression="sortColumn"/>
       <binding name="sortColumn" expression="@org.apache.tapestry.vlib.ejb.SortColumn@TITLE"/>
       <binding name="descending" expression="descending"/>
  -    <binding name="listener" expression="listeners.resort"/>
  +    <binding name="listener" expression="listeners.requery"/>
     </component>   
       
     <component id="sortAuthor" copy-of="sortTitle">
  
  
  
  1.7       +3 -2      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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ViewBook.page	2 Apr 2003 19:22:38 -0000	1.6
  +++ ViewBook.page	7 Apr 2003 18:16:54 -0000	1.7
  @@ -6,7 +6,8 @@
   	
   <page-specification class="org.apache.tapestry.vlib.pages.ViewBook">
     
  -  <property-specification name="book" type="org.apache.tapestry.vlib.ejb.Book" persistent="yes"/>
  +  <property-specification name="bookId" type="java.lang.Integer" persistent="yes"/>
  +  <property-specification name="book" type="org.apache.tapestry.vlib.ejb.Book"/>
     
     <component id="ownerLink" type="PersonLink">
       <binding name="id" expression="book.ownerId"/>
  
  
  
  1.9       +2 -2      jakarta-tapestry/examples/Vlib/context/BorrowedBooks.html
  
  Index: BorrowedBooks.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/BorrowedBooks.html,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- BorrowedBooks.html	2 Apr 2003 19:22:41 -0000	1.8
  +++ BorrowedBooks.html	7 Apr 2003 18:16:55 -0000	1.9
  @@ -22,7 +22,7 @@
       <th><span jwcid="sortOwner">Owner</span></th>
       <th>Return</th>
     </tr>
  -  <tr jwcid="browser@Browser" query="ognl:borrowedQuery" value="ognl:currentBook">
  +  <tr jwcid="browser@Browser" query="ognl:borrowedQuery" value="ognl:currentBook" listener="ognl:listeners.requery">
       <td><a jwcid="@BookLink" book="ognl:currentBook" href="#" class="clsDataBlue">DocBook:The
Definitive Guide</a>
       </td>
       <td><span jwcid="@Insert" value="ognl:currentBook.author">Walsh &#38;
Muellner</span>
  
  
  
  1.8       +3 -3      jakarta-tapestry/examples/Vlib/context/Home.html
  
  Index: Home.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/Home.html,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Home.html	2 Apr 2003 19:22:41 -0000	1.7
  +++ Home.html	7 Apr 2003 18:16:55 -0000	1.8
  @@ -16,12 +16,12 @@
     <table class="form">
       <tr>
         <th>Title</th>
  -      <td><input type="text" jwcid="inputTitle@TextField" value="ognl:title" displaywidth="30"
maximumlength="100"/>
  +      <td><input type="text" jwcid="inputTitle@TextField" value="ognl:title" size="30"
maxlength="100"/>
         </td>
       </tr>
       <tr>
         <th>Author</th>
  -      <td><input type="text" jwcid="inputAuthor@TextField" value="ognl:author"
displaywidth="30" maximumlength="100"/>
  +      <td><input type="text" jwcid="inputAuthor@TextField" value="ognl:author"
size="30" maxlength="100"/>
         </td>
       </tr>
       <tr>
  
  
  
  1.5       +7 -7      jakarta-tapestry/examples/Vlib/context/BookMatches.html
  
  Index: BookMatches.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/BookMatches.html,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BookMatches.html	1 Apr 2003 17:00:29 -0000	1.4
  +++ BookMatches.html	7 Apr 2003 18:16:55 -0000	1.5
  @@ -11,18 +11,18 @@
       <th><span jwcid="sortBorrower">Borrowed&nbsp;By</span></th>
       <th>Borrow</th>
     </tr>
  -    <tr jwcid="browser@Browser" query="ognl:bookQuery" value="ognl:currentMatch">
  -      <td><a href="#" jwcid="@BookLink" book="ognl:currentMatch">DocBook:The
Definitive Guide</a>
  +    <tr jwcid="browser@Browser" query="ognl:bookQuery" value="ognl:currentMatch" listener="ognl:listeners.requery">
  +      <td><a href="#" jwcid="@BookLink" book="ognl:currentMatch">Swing Second
Edition</a>
         </td>
  -      <td><span jwcid="@Insert" value="ognl:currentMatch.author">Walsh &#38;
Muellner</span>
  +      <td><span jwcid="@Insert" value="ognl:currentMatch.author">Robinson and
Vorobiev</span>
         </td>
  -      <td><span jwcid="@Insert" value="ognl:currentMatch.publisherName">O'Reilly</span>
  +      <td><span jwcid="@Insert" value="ognl:currentMatch.publisherName">Manning</span>
         </td>
         <td><a jwcid="ownerLink" href="#">Jim Moran</a>
         </td>
  -      <td><a jwcid="holderLink" href="#">Howard Ship</a>
  +      <td><a jwcid="holderLink" href="#">Howard Lewis Ship</a>
         </td>
  -      <td class="icon"><a jwcid="@Borrow" book="ognl:currentMatch" href="#"><img
src="images/checkout.png" alt="" border="0" vspace="2"></a>
  +      <td class="icon"><a jwcid="@Borrow" book="ognl:currentMatch" href="#"><img
src="images/checkout.png" alt="Borrow" border="0" vspace="2"></a>
         </td>
       </tr>
   </table>
  
  
  
  1.6       +2 -2      jakarta-tapestry/examples/Vlib/context/ViewPerson.html
  
  Index: ViewPerson.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/ViewPerson.html,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ViewPerson.html	2 Apr 2003 19:22:41 -0000	1.5
  +++ ViewPerson.html	7 Apr 2003 18:16:55 -0000	1.6
  @@ -33,7 +33,7 @@
       <th><span jwcid="sortBorrower">Borrowed&nbsp;By</span></th>
       <th>Borrow</th>
     </tr>
  -  <tr jwcid="browser@Browser" query="ognl:query" value="ognl:currentMatch">
  +  <tr jwcid="browser@Browser" query="ognl:query" value="ognl:currentMatch" listener="ognl:listeners.requery">
       <td><a href="#" jwcid="@BookLink" book="ognl:currentMatch">DocBook:The
Definitive Guide</a>
       </td>
       <td><span jwcid="@Insert" value="ognl:currentMatch.author">Walsh &#38;
Muellner</span>
  
  
  
  1.8       +2 -2      jakarta-tapestry/examples/Vlib/context/MyLibrary.html
  
  Index: MyLibrary.html
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/context/MyLibrary.html,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MyLibrary.html	2 Apr 2003 19:22:41 -0000	1.7
  +++ MyLibrary.html	7 Apr 2003 18:16:55 -0000	1.8
  @@ -26,7 +26,7 @@
       <th><span jwcid="sortBorrower">Borrowed By</span></th>
       <th>Edit/Delete</th>
     </tr>
  -  <tr jwcid="browser@Browser" query="ognl:ownedQuery" value="ognl:currentBook">
  +  <tr jwcid="browser@Browser" query="ognl:ownedQuery" value="ognl:currentBook" listener="ognl:listeners.requery">
       <td><span jwcid="@Insert" value="ognl:currentBook.title">DocBook:The Definitive
Guide</span>
       </td>
       <td><span jwcid="@Insert" value="ognl:currentBook.author">Walsh &#38;
Muellner</span>
  
  
  
  1.2       +27 -1     jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/Global.java
  
  Index: Global.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/Global.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Global.java	2 Apr 2003 19:22:44 -0000	1.1
  +++ Global.java	7 Apr 2003 18:16:55 -0000	1.2
  @@ -117,6 +117,26 @@
               {
                   Object raw = getRootNamingContext().lookup(name);
   
  +                if (raw == null)
  +                {
  +                    String message =
  +                        "JNDI lookup of "
  +                            + name
  +                            + " yielded null; expected instance of "
  +                            + expectedClass.getName()
  +                            + ".";
  +
  +                    LOG.error(message);
  +
  +                    if (i++ == 0)
  +                    {
  +                        clear();
  +                        continue;
  +                    }
  +
  +                    throw new ApplicationRuntimeException(message);
  +                }
  +
                   result = PortableRemoteObject.narrow(raw, expectedClass);
   
                   break;
  @@ -132,7 +152,10 @@
                   String message = "Unable to resolve object " + name + ".";
   
                   if (i++ == 0)
  +                {
                       LOG.error(message, ex);
  +                    clear();
  +                }
                   else
                       throw new ApplicationRuntimeException(message, ex);
               }
  @@ -159,7 +182,10 @@
                       String message = "Unable to locate root naming context.";
   
                       if (i++ == 0)
  +                    {
                           LOG.error(message, ex);
  +                        clear();
  +                    }
                       else
                           throw new ApplicationRuntimeException(message, ex);
                   }
  
  
  
  1.7       +16 -1     jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/VirtualLibraryEngine.java
  
  Index: VirtualLibraryEngine.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/VirtualLibraryEngine.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- VirtualLibraryEngine.java	3 Apr 2003 23:47:19 -0000	1.6
  +++ VirtualLibraryEngine.java	7 Apr 2003 18:16:55 -0000	1.7
  @@ -55,6 +55,7 @@
   
   package org.apache.tapestry.vlib;
   
  +import java.io.IOException;
   import java.rmi.RemoteException;
   
   import javax.ejb.CreateException;
  @@ -66,6 +67,7 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.tapestry.ApplicationRuntimeException;
   import org.apache.tapestry.IRequestCycle;
  +import org.apache.tapestry.StaleSessionException;
   import org.apache.tapestry.engine.BaseEngine;
   import org.apache.tapestry.form.IPropertySelectionModel;
   import org.apache.tapestry.request.ResponseOutputStream;
  @@ -484,6 +486,19 @@
           }
   
           return result;
  +    }
  +
  +    protected void handleStaleSessionException(
  +        StaleSessionException ex,
  +        IRequestCycle cycle,
  +        ResponseOutputStream output)
  +        throws IOException, ServletException
  +    {
  +		IMessageProperty home = (IMessageProperty)cycle.getPage("Home");
  +		
  +		home.setMessage("You have been logged out due to inactivity.");
  +		
  +		redirect("Home", cycle, output, ex);
       }
   
   }
  
  
  
  1.5       +5 -3      jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/Visit.java
  
  Index: Visit.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/examples/Vlib/src/org/apache/tapestry/vlib/Visit.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Visit.java	3 Apr 2003 23:47:19 -0000	1.4
  +++ Visit.java	7 Apr 2003 18:16:55 -0000	1.5
  @@ -75,6 +75,8 @@
   
   public class Visit implements Serializable
   {
  +	private static final long serialVersionUID = 8589862098677603655L;
  +	
       /**
        *  Used to identify the logged in user.
        *
  @@ -116,8 +118,8 @@
           if (_userId == null)
               return null;
   
  -		VirtualLibraryEngine vengine = (VirtualLibraryEngine)cycle.getEngine();
  -		
  +        VirtualLibraryEngine vengine = (VirtualLibraryEngine) cycle.getEngine();
  +
           _user = vengine.readPerson(_userId);
   
           return _user;
  
  
  
  1.5       +64 -37    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Browser.java	31 Mar 2003 21:50:08 -0000	1.4
  +++ Browser.java	7 Apr 2003 18:16:55 -0000	1.5
  @@ -58,10 +58,14 @@
   import java.rmi.RemoteException;
   
   import org.apache.tapestry.AbstractComponent;
  -import org.apache.tapestry.ApplicationRuntimeException;
  +import org.apache.tapestry.IActionListener;
   import org.apache.tapestry.IMarkupWriter;
  +import org.apache.tapestry.IPage;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.Tapestry;
  +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;
   
  @@ -74,7 +78,7 @@
    *
    **/
   
  -public abstract class Browser extends AbstractComponent
  +public abstract class Browser extends AbstractComponent implements PageRenderListener
   {
       public abstract IBookQuery getQuery();
   
  @@ -106,6 +110,12 @@
   
       public abstract void setValue(Object value);
   
  +    public abstract IActionListener getListener();
  +
  +    public abstract Object[] getPageResults();
  +
  +    public abstract void setPageResults(Object[] pageResults);
  +
       /**
        *  Invoked by the container when the query (otherwise accessed via the query
        *  parameter) changes.  Re-caches the number of results and sets the current page
  @@ -145,35 +155,6 @@
           return result;
       }
   
  -    /**
  -     *  Returns a subset of the results from the query corresponding
  -     *  to the current page of results.  This may be null if there
  -     *  are no results.  All pages but the last have the same
  -     *  number of results, the final page may be short a few.
  -     *
  -     **/
  -
  -    public Book[] getPageResults()
  -    {
  -        int resultCount = getResultCount();
  -        int currentPage = getCurrentPage();
  -
  -        int low = (currentPage - 1) * _pageSize;
  -        int high = Math.min(currentPage * _pageSize, resultCount) - 1;
  -
  -        if (low > high)
  -            return null;
  -
  -        try
  -        {
  -            return getQuery().get(low, high - low + 1);
  -        }
  -        catch (RemoteException ex)
  -        {
  -            throw new ApplicationRuntimeException(ex);
  -        }
  -    }
  -
       public void jump(int page)
       {
           if (page < 2)
  @@ -191,15 +172,15 @@
   
           setCurrentPage(page);
       }
  -    
  +
       public boolean getDisableBack()
       {
  -    	return getCurrentPage() <= 1;
  +        return getCurrentPage() <= 1;
       }
  -    
  +
       public boolean getDisableNext()
       {
  -		return getCurrentPage() >= getPageCount();
  +        return getCurrentPage() >= getPageCount();
       }
   
       public String getRange()
  @@ -215,7 +196,7 @@
   
       protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
       {
  -        Book[] books = getPageResults();
  +        Object[] books = getPageResults();
           int count = Tapestry.size(books);
   
           for (int i = 0; i < count; i++)
  @@ -241,6 +222,52 @@
       protected void finishLoad()
       {
           setElement("tr");
  +    }
  +
  +    public void pageBeginRender(PageEvent event)
  +    {
  +        int resultCount = getResultCount();
  +        int currentPage = getCurrentPage();
  +
  +        int low = (currentPage - 1) * _pageSize;
  +        int high = Math.min(currentPage * _pageSize, resultCount) - 1;
  +
  +        if (low > high)
  +            return;
  +
  +        Book[] pageResults = null;
  +        int i = 0;
  +
  +        while (true)
  +        {
  +
  +            try
  +            {
  +                pageResults = getQuery().get(low, high - low + 1);
  +
  +                break;
  +            }
  +            catch (RemoteException ex)
  +            {
  +                IPage page = getPage();
  +
  +                if (i++ == 0)
  +                    getListener().actionTriggered(this, page.getRequestCycle());
  +                else
  +                {
  +                    VirtualLibraryEngine vengine = (VirtualLibraryEngine) page.getEngine();
  +                    vengine.rmiFailure("Unable to retrieve query results.", ex, i);
  +                }
  +
  +            }
  +        }
  +
  +        setPageResults(pageResults);
  +    }
  +
  +    public void pageEndRender(PageEvent event)
  +    {
  +        setPageResults(null);
       }
   
   }
  
  
  

Mime
View raw message