|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.arsdigita.bebop.Completable
com.arsdigita.bebop.CompoundComponent
Provides a convenient method of creating components that are an aggregation of other components and that should have the public interface of a component (rather than that of a container, form, and so on). The methods of the Component interface are delegated to a Container object, which is a SimpleContainer by default. The methods of the Container interface are present with protected access. This allows subclasses of CompoundComponent to alter the structure of the component while preserving the simple Component interface to users of the class.
Users of this class should subclass CompoundComponent and add components in the subclass' constructor, remembering to first call super() or super( Container ). Note that the super( Container ) method will use the passed Container in place of the SimpleContainer to hold the added components.
| Field Summary |
| Fields inherited from class com.arsdigita.bebop.Completable |
versionId |
| Fields inherited from interface com.arsdigita.bebop.Component |
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE, versionId |
| Constructor Summary | |
CompoundComponent()
Creates a new compound component. |
|
CompoundComponent(Container container)
Creates a new compound component, using the specified container to hold added components. |
|
| Method Summary | |
protected void |
add(Component c)
Adds a component to the container. |
protected void |
add(Component c,
int constraints)
Adds a component with the specified layout constraints to the container. |
Iterator |
children()
Returns an iterator over the children of this component. |
protected boolean |
contains(Object o)
Returns true if this list contains the specified element. |
void |
generateXML(PageState state,
Element parent)
Adds a DOM subtree representing this component under the given parent node. |
protected Component |
get(int index)
Gets the component at the specified position. |
String |
getClassAttr()
Gets the class attribute. |
protected Container |
getContainer()
Return the Container used to hold added components. |
String |
getIdAttr()
Gets the id attribute. |
String |
getKey()
Retrieves the programmer-supplied key. |
String |
getStyleAttr()
Gets the style attribute. |
protected int |
indexOf(Component c)
|
protected boolean |
isEmpty()
Returns true if the container contains no components. |
boolean |
isLocked()
Return whether an object is locked and thus immutable, or can still be modified. |
boolean |
isVisible(PageState state)
Determines whether the component is visible in the request represented by state. |
void |
lock()
Lock an object. |
void |
register(Form f,
FormModel m)
Registers form parameters with the form model for this form. |
void |
register(Page p)
Registers state parameters for the page with its model. |
void |
respond(PageState state)
Responds to the request. |
void |
setClassAttr(String theClass)
Sets the class attribute. |
void |
setIdAttr(String id)
Sets the id attribute. |
Component |
setKey(String key)
Supplies a key for making parameter names unique. |
void |
setStyleAttr(String style)
Sets the style attribute. |
void |
setVisible(PageState state,
boolean v)
Changes the visibility of the component. |
protected int |
size()
Returns the number of elements in the container. |
| Methods inherited from class com.arsdigita.bebop.Completable |
addCompletionListener, fireCompletionEvent |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public CompoundComponent()
public CompoundComponent(Container container)
container - container to hold added components| Method Detail |
protected Container getContainer()
protected void add(Component c)
c - the component to addContainer.add( Component )
protected void add(Component c,
int constraints)
c - the component to add to the containerconstraints - layout constraints (a
bitwise OR of static ints in the particular layout)Container.add( Component, int )protected boolean contains(Object o)
true if this list contains the specified element.
More formally, returns
true if and only if this list contains at least
one element e such that (o==null ? e==null : o.equals(e)).
This method returns trueonly if the object has been
directly added to the container. If the container contains another
container that contains this object, this method returns
false.
o - element whose presence in the container is to be tested
true if the container contains the specified
object directly; false otherwise.Container.contains( Object )protected Component get(int index)
index - the index of the item to be retrieved from this
container
protected int indexOf(Component c)
c - the component to search for
Container.indexOf( Component )protected boolean isEmpty()
true if the container contains no components.
true if the container contains no components;
false otherwise.Container.isEmpty()protected int size()
Container.size()public Iterator children()
Componentnull) iterator.
children in interface ComponentComponent.children()
public void generateXML(PageState state,
Element parent)
ComponentAdds a DOM subtree representing this component under the given
parent node. Uses the request values stored in state.
generateXML in interface Componentstate - represents the current requestparent - the node under which the DOM subtree should be addedComponent.generateXML( PageState, Element )public String getClassAttr()
Component
getClassAttr in interface ComponentComponent.getClassAttr()public String getIdAttr()
Component
getIdAttr in interface ComponentComponent.getIdAttr()public String getKey()
Component
getKey in interface ComponentComponent.getKey()public String getStyleAttr()
Component
getStyleAttr in interface ComponentComponent.getStyleAttr()public boolean isVisible(PageState state)
Componentstate.
isVisible in interface Componentstate - represents the current request
true if the component is visible in the request;
false otherwise.Component.isVisible( PageState )
public void register(Form f,
FormModel m)
Componentform
sections and widgets
(components that have a connection to an HTML form). Other
components can implement it as a no-op.
register in interface ComponentComponent.register( Form, FormModel )public void register(Page p)
Componentparam 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"
register in interface ComponentComponent.register( Page )
public void respond(PageState state)
throws javax.servlet.ServletException
ComponentResponds to the request. This method is only called if the request
was made from a link or form that the component put on the page in the
PageState.stateAsURL() previous request.
No output should be generated on the HTTP response. The component
can store intermediate results in the state by calling
setAttribute.
This method is called before any output is printed to the HTTP response so that the component can forward to a different page and thereby commit the response.
respond in interface Componentstate - represents the current request
javax.servlet.ServletExceptionComponent.respond( PageState )public void setClassAttr(String theClass)
Component
setClassAttr in interface ComponenttheClass - a valid XML nameComponent.setClassAttr( String )public void setIdAttr(String id)
Componentid
should be an XML name
that is unique within the Page in which this component is
contained. The value of id is copied literally to the
output and not used for internal processing.
setIdAttr in interface Componentid - a valid XML identifierComponent.setIdAttr( String )public Component setKey(String key)
Component
setKey in interface ComponentComponent.setKey( String )public void setStyleAttr(String style)
Componentstyle should be a valid CSS
style, because its value will be copied verbatim to the output and
appear as a style attribute in the top level XML or HTML
output element.
setStyleAttr in interface Componentstyle - a valid CSS style description for use in the
style attribute of an HTML tagComponent.setStyleAttr( String )
public void setVisible(PageState state,
boolean v)
Component
setVisible in interface Componentstate - represents the current requestv - true if the component should be visibleComponent.setVisible( PageState, boolean )public void lock()
LockablesetXXX method
should lead to an exception.
Most lockable Bebop classes throw an IllegalStateException if an attempt is made to modify a
locked instance.
lock in interface LockableLockable.lock()public boolean isLocked()
Lockable
isLocked in interface LockableLockable.isLocked()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||