1
2
3
4
5
6
7
8
9
10
11
12
13
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 public abstract class BeanFormRows extends BeanFormComponent {
35
36 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 return this.property;
43 }
44
45 public void setProperty( BeanProperty property ) {
46 this.property = property;
47 this.fieldBindings = this.getBeanForm().getFieldBindingsFor( property );
48 }
49
50 public List<BeanProperty> getProperties() {
51 return this.getBeanForm().getBeanProperties();
52 }
53
54 @Override
55 protected void renderComponent( IMarkupWriter writer, IRequestCycle cycle ) {
56 Object old = cycle.getAttribute( BEAN_FORM_ROWS_ATTRIBUTE );
57 cycle.setAttribute( BEAN_FORM_ROWS_ATTRIBUTE, this );
58 super.renderComponent( writer, cycle );
59 cycle.setAttribute( BEAN_FORM_ROWS_ATTRIBUTE, old );
60 }
61
62 protected void addExtraBindings( IFormComponent field ) {
63 DualBinding.addCustomBindings( field, this.fieldBindings, true );
64 }
65
66 }