com.arsdigita.bebop
Class SimpleComponent

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
All Implemented Interfaces:
Cloneable, Component, Lockable
Direct Known Subclasses:
Column, ComponentMap, ComponentSet, ContextBar, DebugPanel, ElementComponent, FilterComponent, FormSection, HorizontalLine, ItemDetail, List, PropertyList, ResultsPane, Section, SiteBanner, SlaveComponent, StaticFilterComponent, TableColumn, TableHeader, TextStylable, Tree, UserBanner

public class SimpleComponent
extends Completable
implements Component, Cloneable

A simple implementation of the Component interface.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/SimpleComponent.java#15 $
Author:
David Lutterkort, Stanislav Freidin, Rory Solomon, Uday Mathur

Field Summary
protected  Attributes m_attr
          The Attribute object is protected to make it easier for the Form Builder service to persist the SimpleComponent.
static String versionId
           
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
SimpleComponent()
           
 
Method Summary
 Iterator children()
          Returns an iterator over the children of this component.
 Object clone()
          Clones a component.
protected  void exportAttributes(Element target)
          Adds the attributes set with setAttribute to the element target.
 void generateXML(PageState state, Element p)
          Adds [J]DOM nodes for this component.
protected  String getAttribute(String name)
          Gets the value of an attribute.
 String getClassAttr()
          Gets the class attribute.
 String getIdAttr()
          Gets the id attribute.
 String getKey()
          Retrieves a key for parameter name mangling.
 String getMetaDataAttribute(String name)
           
 String getStyleAttr()
          Gets the style attribute.
protected  boolean hasAttributes()
          Returns true if any attributes have been set.
 boolean isLocked()
          Return whether an object is locked and thus immutable, or can still be modified.
 boolean isVisible(PageState s)
          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)
          Does processing that is special to the component receiving the click.
protected  void setAttribute(String name, String value)
          Sets an attribute.
 void setClassAttr(String theClass)
          Sets the class attribute.
 void setIdAttr(String id)
          Sets the id attribute.
 Component setKey(String key)
          Supplies a key for parameter name mangling.
 void setMetaDataAttribute(String name, String value)
           
 void setStyleAttr(String style)
          Sets the style attribute.
 void setVisible(PageState s, boolean v)
          Changes the visibility of the component.
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

m_attr

protected Attributes m_attr
The Attribute object is protected to make it easier for the Form Builder service to persist the SimpleComponent. Locking violation is not a problem since if the SimpleComponent is locked then the Attribute object will also be locked.

Constructor Detail

SimpleComponent

public SimpleComponent()
Method Detail

clone

public Object clone()
             throws CloneNotSupportedException
Clones a component. The clone is not locked and has its own set of attributes.

Returns:
the clone of a component.
Throws:
CloneNotSupportedException

register

public void register(Page p)
Description copied from interface: Component
Registers state parameters for the page with its model. 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"

Specified by:
register in interface Component

register

public void register(Form f,
                     FormModel m)
Description copied from interface: Component
Registers form parameters with the form model for this form. This method is only important for form sections and widgets (components that have a connection to an HTML form). Other components can implement it as a no-op.

Specified by:
register in interface Component

respond

public void respond(PageState state)
             throws javax.servlet.ServletException
Does processing that is special to the component receiving the click.

Specified by:
respond in interface Component
Parameters:
state - the current page state
Throws:
javax.servlet.ServletException

children

public Iterator children()
Description copied from interface: Component
Returns an iterator over the children of this component. If the component has no children, returns an empty (not null) iterator.

Specified by:
children in interface Component
Returns:
an iterator over the children of this component.

generateXML

public void generateXML(PageState state,
                        Element p)
Adds [J]DOM nodes for this component. Specifically for base class SimpleComponent, does nothing.

Specified by:
generateXML in interface Component
Parameters:
state - represents the current request
p - the node under which the DOM subtree should be added

isLocked

public final boolean isLocked()
Description copied from interface: Lockable
Return whether an object is locked and thus immutable, or can still be modified.

Specified by:
isLocked in interface Lockable

lock

public void lock()
Description copied from interface: Lockable
Lock an object. Locked objects are to be considered immutable. Any attempt to modify them, e.g., through a setXXX method should lead to an exception.

Most lockable Bebop classes throw an IllegalStateException if an attempt is made to modify a locked instance.

Specified by:
lock in interface Lockable

getClassAttr

public String getClassAttr()
Gets the class attribute.

Specified by:
getClassAttr in interface Component
Returns:
the class attribute.
See Also:
Component.setClassAttr(String), Standard Attributes

setClassAttr

public void setClassAttr(String theClass)
Sets the class attribute.

Specified by:
setClassAttr in interface Component
Parameters:
theClass - a valid XML name
See Also:
Standard Attributes, Component.getClassAttr()

getStyleAttr

public String getStyleAttr()
Gets the style attribute.

Specified by:
getStyleAttr in interface Component
Returns:
the style attribute.
See Also:
Component.setStyleAttr(java.lang.String), Standard Attributes

setStyleAttr

public void setStyleAttr(String style)
Sets the style attribute. style should be a valid CSS style, since its value will be copied verbatim to the output and appear as a style attribute in the top level XML or HTML output element.

Specified by:
setStyleAttr in interface Component
Parameters:
style - a valid CSS style description for use in the style attribute of an HTML tag
See Also:
Standard Attributes

getIdAttr

public String getIdAttr()
Gets the id attribute.

Specified by:
getIdAttr in interface Component
Returns:
the id attribute.
See Also:
setIdAttr(String id)

setIdAttr

public void setIdAttr(String id)
Sets the id attribute. id 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.

Specified by:
setIdAttr in interface Component
Parameters:
id - a valid XML identifier
See Also:
Standard Attributes

setAttribute

protected final void setAttribute(String name,
                                  String value)
Sets an attribute. Overwrites any old values. These values are used to generate attributes for the top level XML or HTML element that is output from this component with generateXML.

Parameters:
name - attribute name, case insensitive
value - new attribute value

getAttribute

protected final String getAttribute(String name)
Gets the value of an attribute.

Parameters:
name - attribute name, case insensitive
Returns:
the string value previously set with setAttribute, or null if none was set.
See Also:
setAttribute(java.lang.String, java.lang.String)

exportAttributes

protected final void exportAttributes(Element target)
Adds the attributes set with setAttribute to the element target. The attributes set with exportAttributes overwrite attributes with identical names that target might already have.

Parameters:
target - element to which attributes are added
See Also:
setAttribute(java.lang.String, java.lang.String)

hasAttributes

protected final boolean hasAttributes()
Returns true if any attributes have been set.

Returns:
true if any attributes have been set; false otherwise.

setMetaDataAttribute

public final void setMetaDataAttribute(String name,
                                       String value)

getMetaDataAttribute

public final String getMetaDataAttribute(String name)

setKey

public Component setKey(String key)
Supplies a key for parameter name mangling.

Specified by:
setKey in interface Component
Parameters:
key - the key to mangle

getKey

public final String getKey()
Retrieves a key for parameter name mangling.

Specified by:
getKey in interface Component
Returns:
a key for parameter name mangling.

isVisible

public boolean isVisible(PageState s)
Description copied from interface: Component
Determines whether the component is visible in the request represented by state.

Specified by:
isVisible in interface Component
Parameters:
s - represents the current request
Returns:
true if the component is visible in the request; false otherwise.
See Also:
setVisible, Description of Visibility above

setVisible

public void setVisible(PageState s,
                       boolean v)
Description copied from interface: Component
Changes the visibility of the component. The component will keep the visibility that is set with this method in subsequent requests to this page.

Specified by:
setVisible in interface Component
Parameters:
s - represents the current request
v - true if the component should be visible
See Also:
Description of Visibility above


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC