From 2fde32df93d341e30f04b2c3fa2f502c70f634b3 Mon Sep 17 00:00:00 2001 From: pb Date: Wed, 30 Oct 2013 08:46:48 +0000 Subject: [PATCH] Added documentation git-svn-id: https://svn.libreccm.org/ccm/trunk@2404 8810af33-2d31-482b-a856-94f89814c4df --- .../src/com/arsdigita/bebop/Component.java | 6 ++- .../com/arsdigita/bebop/ModalContainer.java | 15 ++++++- .../com/arsdigita/bebop/SimpleComponent.java | 40 +++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) diff --git a/ccm-core/src/com/arsdigita/bebop/Component.java b/ccm-core/src/com/arsdigita/bebop/Component.java index 964e9107f..f143f2283 100755 --- a/ccm-core/src/com/arsdigita/bebop/Component.java +++ b/ccm-core/src/com/arsdigita/bebop/Component.java @@ -249,7 +249,8 @@ public interface Component extends Lockable { * malfunction and produce errors like "Widget ... isn't * associated with any Form" * - * @pre p != null */ + * @pre p != null + */ void register(Page p); /** @@ -260,7 +261,8 @@ public interface Component extends Lockable { * components can implement it as a no-op. * * @pre f != null - * @pre m != null */ + * @pre m != null + */ void register(Form f, FormModel m); /* Properties that will get copied straight to the output, diff --git a/ccm-core/src/com/arsdigita/bebop/ModalContainer.java b/ccm-core/src/com/arsdigita/bebop/ModalContainer.java index 93c30a4c8..568ad687b 100755 --- a/ccm-core/src/com/arsdigita/bebop/ModalContainer.java +++ b/ccm-core/src/com/arsdigita/bebop/ModalContainer.java @@ -26,7 +26,7 @@ import java.util.Iterator; import org.apache.log4j.Logger; /** - * A modal container is a container that manages visibility for a set of + * ModalContainer is a container that manages visibility for a set of * components. It allows only one of its children to be visible. One of its * children can be selected as the default visible component. If none is * selected the child with index equal to zero is used. The modal container @@ -53,6 +53,19 @@ public class ModalContainer extends SimpleContainer implements Resettable { super(tagName, xmlns); } + /** + * Registers state parameters for the page with its model. + * + * Used here to set the visibility of the component. + * + * The super class' method is empty, so the rule "Always call + * super.register when you override register + * doessn't apply here. + * + * @pre p != null + * @param p + */ + @Override public void register(Page p) { Assert.isUnlocked(this); diff --git a/ccm-core/src/com/arsdigita/bebop/SimpleComponent.java b/ccm-core/src/com/arsdigita/bebop/SimpleComponent.java index b318dd97a..903804865 100755 --- a/ccm-core/src/com/arsdigita/bebop/SimpleComponent.java +++ b/ccm-core/src/com/arsdigita/bebop/SimpleComponent.java @@ -68,10 +68,50 @@ public class SimpleComponent extends Completable return result; } + /** + * Registers state parameters for the page with its model. Documentation + * from Interface Componment: + * + * A simple component with a state parameter param would do + * the following in the body of this method: + *
+     *   p.addComponent(this);
+     *   p.addComponentStateParam(this, param);
+     * 
+ * + * You should override this method to set the default visibility + * of your component: + * + *
+     * public void register(Page p) {
+     *     super.register(p);
+     *     p.setVisibleDefault(childNotInitiallyShown,false);
+     *     p.setVisibleDefault(anotherChild, false);
+     * }
+     * 
+ * + * Always call super.register when you override + * register. Otherwise your component may + * malfunction and produce errors like "Widget ... isn't + * associated with any Form" + * + * @pre p != null + * @param p + */ public void register(Page p) { return; } + /** + * Registers form parameters with the form model for this form. + * This method is only important for {@link FormSection form sections} + * and {@link com.arsdigita.bebop.form.Widget widgets} (components that + * have a connection to an HTML form). Other components can implement it + * as a no-op. + * + * @pre f != null + * @pre m != null + */ public void register(Form f, FormModel m) { return; }