Coverage Report - org.trails.page.ListPage
 
Classes in this File Line Coverage Branch Coverage Complexity
ListPage
92% 
N/A 
1
 
 1  
 /*
 2  
  * Copyright 2004 Chris Nelson
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 7  
  * Unless required by applicable law or agreed to in writing,
 8  
  * software distributed under the License is distributed on an "AS IS" BASIS,
 9  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 10  
  * See the License for the specific language governing permissions and limitations under the License.
 11  
  */
 12  
 package org.trails.page;
 13  
 
 14  
 import java.util.List;
 15  
 
 16  
 import org.apache.tapestry.IExternalPage;
 17  
 import org.apache.tapestry.IRequestCycle;
 18  
 import org.apache.tapestry.event.PageBeginRenderListener;
 19  
 import org.trails.TrailsRuntimeException;
 20  
 import org.trails.callback.ListCallback;
 21  
 import org.trails.component.TrailsTableColumn;
 22  
 import org.trails.component.Utils;
 23  
 import org.trails.descriptor.IClassDescriptor;
 24  
 
 25  
 /**
 26  
  * List all the instances of a type
 27  
  * 
 28  
  * @author Chris Nelson
 29  
  */
 30  19
 public abstract class ListPage extends TrailsPage implements IExternalPage, PageBeginRenderListener
 31  
 {
 32  
 
 33  
         /**
 34  
          * (non-Javadoc)
 35  
          * 
 36  
          * @see org.apache.tapestry.IExternalPage#activateExternalPage(java.lang.Object[],org.apache.tapestry.IRequestCycle)
 37  
          */
 38  
         public void activateExternalPage(Object[] args, IRequestCycle cycle)
 39  
         {
 40  1
                 Class instanceClass = (Class) args[0];
 41  1
                 setType(instanceClass);
 42  1
                 reloadInstances();
 43  1
         }
 44  
 
 45  
         public abstract List getInstances();
 46  
 
 47  
         public abstract void setInstances(List Instances);
 48  
 
 49  
         public abstract TrailsTableColumn getColumn();
 50  
 
 51  
         public abstract void setColumn(TrailsTableColumn column);
 52  
 
 53  
         public abstract Class getType();
 54  
 
 55  
         public abstract void setType(Class type);
 56  
 
 57  
         public IClassDescriptor getClassDescriptor()
 58  
         {
 59  0
                 return getDescriptorService().getClassDescriptor(getType());
 60  
         }
 61  
 
 62  
         public void pushCallback()
 63  
         {
 64  2
                 getCallbackStack().push(new ListCallback(getPageName(), getType()));
 65  2
         }
 66  
 
 67  
         private void loadInstances(Class clazz)
 68  
         {
 69  1
                 setInstances(getPersistenceService().getAllInstances(clazz));
 70  1
         }
 71  
 
 72  
         public void reloadInstances()
 73  
         {
 74  1
                 loadInstances(getType());
 75  1
         }
 76  
 }