Coverage Report - net.sf.beanform.BeanFormRows
 
Classes in this File Line Coverage Branch Coverage Complexity
BeanFormRows
93% 
N/A 
0
 
 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 java.util.List;
 18  
 import java.util.Map;
 19  
 
 20  
 import net.sf.beanform.binding.DualBinding;
 21  
 import net.sf.beanform.prop.BeanProperty;
 22  
 
 23  
 import org.apache.tapestry.IBinding;
 24  
 import org.apache.tapestry.IMarkupWriter;
 25  
 import org.apache.tapestry.IRequestCycle;
 26  
 import org.apache.tapestry.form.IFormComponent;
 27  
 
 28  
 /**
 29  
  * A low level BeanForm component that generates the rows for all the properties.
 30  
  * This component must be wrapped by a {@link BeanForm} component.
 31  
  *
 32  
  * @author Daniel Gredler
 33  
  */
 34  9
 public abstract class BeanFormRows extends BeanFormComponent {
 35  
 
 36  1
     public final static String BEAN_FORM_ROWS_ATTRIBUTE = BeanFormRows.class.getName();
 37  
 
 38  
     private BeanProperty property;
 39  
     private Map<String, IBinding> fieldBindings;
 40  
 
 41  
     public BeanProperty getProperty() {
 42  5
         return this.property;
 43  
     }
 44  
 
 45  
     public void setProperty( BeanProperty property ) {
 46  1
         this.property = property;
 47  1
         this.fieldBindings = this.getBeanForm().getFieldBindingsFor( property );
 48  1
     }
 49  
 
 50  
     public List<BeanProperty> getProperties() {
 51  0
         return this.getBeanForm().getBeanProperties();
 52  
     }
 53  
 
 54  
     @Override
 55  
     protected void renderComponent( IMarkupWriter writer, IRequestCycle cycle ) {
 56  1
         Object old = cycle.getAttribute( BEAN_FORM_ROWS_ATTRIBUTE );
 57  1
         cycle.setAttribute( BEAN_FORM_ROWS_ATTRIBUTE, this );
 58  1
         super.renderComponent( writer, cycle );
 59  1
         cycle.setAttribute( BEAN_FORM_ROWS_ATTRIBUTE, old );
 60  1
     }
 61  
 
 62  
     protected void addExtraBindings( IFormComponent field ) {
 63  1
         DualBinding.addCustomBindings( field, this.fieldBindings, true );
 64  1
     }
 65  
 
 66  
 }