Coverage Report - org.apache.tapestry.contrib.table.components.Table
 
Classes in this File Line Coverage Branch Coverage Complexity
Table
0%
0/20
0%
0/6
1.333
 
 1  
 // Copyright 2004, 2005 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry.contrib.table.components;
 16  
 
 17  
 import org.apache.tapestry.BaseComponent;
 18  
 import org.apache.tapestry.IForm;
 19  
 import org.apache.tapestry.TapestryUtils;
 20  
 import org.apache.tapestry.contrib.table.model.ITableAction;
 21  
 import org.apache.tapestry.contrib.table.model.ITableColumn;
 22  
 import org.apache.tapestry.contrib.table.model.ITableModel;
 23  
 import org.apache.tapestry.contrib.table.model.ITableModelSource;
 24  
 
 25  
 /**
 26  
  * The facade component in the Table family. Table allows you to present a
 27  
  * sortable and pagable table simply and easily by using only this one
 28  
  * component. Please see the Component Reference for details on how to use this
 29  
  * component. [ <a
 30  
  * href="../../../../../../../ComponentReference/contrib.Table.html">Component
 31  
  * Reference </a>]
 32  
  * 
 33  
  * @author mindbridge
 34  
  */
 35  0
 public abstract class Table extends BaseComponent implements ITableModelSource
 36  
 {
 37  
 
 38  
     public abstract boolean getVolatile();
 39  
 
 40  
     /**
 41  
      * @see org.apache.tapestry.contrib.table.model.ITableModelSource#getTableModel()
 42  
      */
 43  
     public ITableModel getTableModel()
 44  
     {
 45  0
         return getTableViewComponent().getTableModel();
 46  
     }
 47  
 
 48  
     /**
 49  
      * Indicates that the table model has changed and it may need to saved. This
 50  
      * method has to be invoked if modifications are made to the model.
 51  
      * 
 52  
      * @see org.apache.tapestry.contrib.table.model.ITableModelSource#fireObservedStateChange()
 53  
      */
 54  
     public void fireObservedStateChange()
 55  
     {
 56  0
         getTableViewComponent().fireObservedStateChange();
 57  0
     }
 58  
 
 59  
     /**
 60  
      * Resets the state of the component and forces it to load a new TableModel
 61  
      * from the tableModel binding the next time it renders.
 62  
      */
 63  
     public void reset()
 64  
     {
 65  0
         getTableViewComponent().reset();
 66  0
     }
 67  
 
 68  
     /**
 69  
      * Returns the currently rendered table column. You can call this method to
 70  
      * obtain the current column.
 71  
      * 
 72  
      * @return ITableColumn the current table column
 73  
      */
 74  
     public ITableColumn getTableColumn()
 75  
     {
 76  0
         Object objCurrentRow = getTableRow();
 77  
 
 78  
         // if the current row is null, then we are most likely rendering
 79  
         // TableColumns
 80  0
         if (objCurrentRow == null)
 81  0
             return getTableColumnsComponent().getTableColumn();
 82  
 
 83  0
         return getTableValuesComponent().getTableColumn();
 84  
     }
 85  
 
 86  
     /**
 87  
      * Returns the currently rendered table row or null if the rows are not
 88  
      * rendered at the moment. You can call this method to obtain the current
 89  
      * row.
 90  
      * 
 91  
      * @return Object the current table row
 92  
      */
 93  
     public Object getTableRow()
 94  
     {
 95  0
         return getTableRowsComponent().getTableRow();
 96  
     }
 97  
 
 98  
     protected TableView getTableViewComponent()
 99  
     {
 100  0
         return (TableView) getComponent("tableView");
 101  
     }
 102  
 
 103  
     protected TableColumns getTableColumnsComponent()
 104  
     {
 105  0
         return (TableColumns) getComponent("tableColumns");
 106  
     }
 107  
 
 108  
     protected TableRows getTableRowsComponent()
 109  
     {
 110  0
         return (TableRows) getComponent("tableRows");
 111  
     }
 112  
 
 113  
     protected TableValues getTableValuesComponent()
 114  
     {
 115  0
         return (TableValues) getComponent("tableValues");
 116  
     }
 117  
 
 118  
     public boolean getShowNormalPages()
 119  
     {
 120  0
         if (getVolatile()) return true;
 121  
 
 122  0
         IForm form = (IForm) getPage().getRequestCycle().getAttribute(
 123  
                 TapestryUtils.FORM_ATTRIBUTE);
 124  0
         return (form == null);
 125  
     }
 126  
 
 127  
     /*
 128  
      * (non-Javadoc)
 129  
      * 
 130  
      * @see org.apache.tapestry.contrib.table.model.ITableModelSource#storeTableAction(org.apache.tapestry.contrib.table.model.ITableAction)
 131  
      */
 132  
     public void storeTableAction(ITableAction action)
 133  
     {
 134  0
         getTableViewComponent().storeTableAction(action);
 135  0
     }
 136  
 }