Coverage Report - net.sf.beanform.BeanFormRowComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
BeanFormRowComponent
69% 
100% 
1.286
 
 1  
 // Copyright 2006 Daniel Gredler
 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 net.sf.beanform;
 16  
 
 17  
 import net.sf.beanform.prop.BeanProperty;
 18  
 
 19  
 import org.apache.hivemind.ApplicationRuntimeException;
 20  
 import org.apache.tapestry.IRequestCycle;
 21  
 import org.apache.tapestry.components.Block;
 22  
 import org.apache.tapestry.form.IFormComponent;
 23  
 
 24  
 /**
 25  
  * Superclass for low level BeanForm components which must be wrapped by
 26  
  * a {@link BeanFormRows} component.
 27  
  *
 28  
  * @see BeanFormLabel
 29  
  * @see BeanFormField
 30  
  *
 31  
  * @author Daniel Gredler
 32  
  */
 33  33
 public abstract class BeanFormRowComponent extends BeanFormComponent {
 34  
 
 35  
     public Object getBean() {
 36  1
         return this.getBeanFormRows().getBeanForm().getBeanSafely();
 37  
     }
 38  
 
 39  
     public BeanProperty getProperty() {
 40  2
         return this.getBeanFormRows().getProperty();
 41  
     }
 42  
 
 43  
     public String getDisplayName() {
 44  1
         String name = this.getProperty().getName();
 45  1
         return this.getPage().getMessages().getMessage( name );
 46  
     }
 47  
 
 48  
     protected void addExtraBindings( IFormComponent field ) {
 49  0
         this.getBeanFormRows().addExtraBindings( field );
 50  0
     }
 51  
 
 52  
     private BeanFormRows getBeanFormRows() {
 53  3
         IRequestCycle cycle = this.getPage().getRequestCycle();
 54  3
         BeanFormRows rows = (BeanFormRows) cycle.getAttribute( BeanFormRows.BEAN_FORM_ROWS_ATTRIBUTE );
 55  3
         if( rows == null ) throw new ApplicationRuntimeException( BeanFormMessages.noBeanFormRows( this ) );
 56  3
         return rows;
 57  
     }
 58  
 
 59  
     public Block getCustomFieldBlock() {
 60  0
         return this.getCustomFieldBlock( this.getProperty() );
 61  
     }
 62  
 
 63  
     public IFormComponent getCustomField() {
 64  0
         return this.getCustomField( this.getProperty() );
 65  
     }
 66  
 
 67  
 }