org.enhydra.barracuda.core.comp
Class BComponent

java.lang.Object
  extended byorg.enhydra.barracuda.core.comp.AbstractBComponent
      extended byorg.enhydra.barracuda.core.comp.BComponent
All Implemented Interfaces:
BContainer, StateMap
Direct Known Subclasses:
BAction, BInput, BList, BScript, BScriptResource, BTable, BTemplate, BText

public class BComponent
extends AbstractBComponent

Defines the base component class from which all other Barracuda components are derived. Its Swing counterpart would be JComponent.


Field Summary
protected  Map attrs
           
protected  boolean enabled
           
protected static org.apache.log4j.Logger logger
           
protected  String name
           
protected  RenderStrategy rs
           
static String VISIBILITY_MARKER
           
protected  boolean visible
           
 
Fields inherited from class org.enhydra.barracuda.core.comp.AbstractBComponent
children, dvc, isStepChild, parent, statemap, stepChildren, tempViews, validated, views
 
Constructor Summary
BComponent()
           
 
Method Summary
 void addView(View view)
          Bind a component to a view
 Object getAttr(Object attr)
          get an attribute associated with this particular component.
 Map getAttrMap()
          get a copy of the underlying component attribute Map
protected  View getFirstView()
           
 String getName()
          Get the name for this component
 RenderStrategy getRenderStrategy()
          Get the render strategy for this component
 List getViews()
          Get a list of all the views for this component.
 boolean isEnabled()
          See if the component is enabled
 boolean isVisible()
          Get the component visibility
protected  void postRender(ViewContext vc, int depth)
          Cleanup after rendering.
protected  void preRender(ViewContext vc, int depth)
          Prep phase before rendering.
 void removeAllViews()
          Remove all views from this component
 boolean removeView(View view)
          Remove a view from this component
 void render(ViewContext vc)
          Render the component for a view with the specified ViewContext.
protected  void render(ViewContext vc, int depth)
           
protected  void renderView(View view, ViewContext vc)
          Render a specific view for the component.
protected  void renderView(View view, ViewContext vc, int depth)
           
 void setAttr(Object attr, Object val)
          set an attribute for this particular component.
 void setEnabled(boolean val)
          Enable/disable the component
 void setEnabled(boolean val, boolean recurse)
          Enable/disable the component recursively
 void setName(String iname)
          Set the name for this component.
 void setRenderStrategy(RenderStrategy irs)
          Set the render strategy for this component and all its children.
 void setView(View view)
          Set the components primary view.
 void setVisible(boolean val)
          Set the component visibility
 void setVisible(boolean val, boolean recurse)
          Set the component visibility recursively
 boolean supports(ViewContext vc)
          Determine if a specific ViewContext is supported by this component
 
Methods inherited from class org.enhydra.barracuda.core.comp.AbstractBComponent
addChild, addStepChild, addStepChild, addTempView, clearState, destroyCycle, findComponentMap, findRendererFactory, getChild, getChildren, getDefaultViewContext, getParent, getRenderer, getRenderer, getRootComponent, getState, getStateKeys, getStateValues, hasChildren, hasViews, initCycle, installRendererFactory, invalidate, isStepChild, printStackTrace, printStackTrace, printStackTrace, putState, removeAll, removeAllStepChildren, removeChild, removeChild, removeState, setDefaultViewContext, setParent, toRef, toString, toString, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

protected static final org.apache.log4j.Logger logger

VISIBILITY_MARKER

public static final String VISIBILITY_MARKER
See Also:
Constant Field Values

name

protected String name

visible

protected boolean visible

enabled

protected boolean enabled

attrs

protected Map attrs

rs

protected RenderStrategy rs
Constructor Detail

BComponent

public BComponent()
Method Detail

setName

public void setName(String iname)
Set the name for this component.

Note that for several types of views (HTMLAnchorElement, HTMLAppletElement, HTMLButtonElement, HTMLFormElement, HTMLFrameElement, HTMLIFrameElement, HTMLInputElement, HTMLMapElement, HTMLMetaElement, HTMLObjectElement, HTMLParamElement, HTMLSelectElement, and HTMLTextAreaElement) this property will be used in rendering if it is actually set. This means that if you set the component name, and it is bound to a view that is backed by one of these nodes, then the name attribute in that node will be overridden. So be careful!!!

Specified by:
setName in interface BContainer
Specified by:
setName in class AbstractBComponent
Parameters:
iname - the name for this component

getName

public String getName()
Get the name for this component

Specified by:
getName in interface BContainer
Specified by:
getName in class AbstractBComponent
Returns:
the name for this component

setVisible

public void setVisible(boolean val)
Set the component visibility

Specified by:
setVisible in class AbstractBComponent
Parameters:
val - true if the component should be visible

setVisible

public void setVisible(boolean val,
                       boolean recurse)
Set the component visibility recursively

Specified by:
setVisible in class AbstractBComponent
Parameters:
val - true if the component should be visible
recurse - true if we want to set this value recursively

isVisible

public boolean isVisible()
Get the component visibility

Specified by:
isVisible in class AbstractBComponent
Returns:
true if the component is visible

setEnabled

public void setEnabled(boolean val)
Enable/disable the component

Specified by:
setEnabled in class AbstractBComponent
Parameters:
val - true if the component should be enabled

setEnabled

public void setEnabled(boolean val,
                       boolean recurse)
Enable/disable the component recursively

Specified by:
setEnabled in class AbstractBComponent
Parameters:
val - true if the component should be enabled
recurse - true if we want to set this value recursively

isEnabled

public boolean isEnabled()
See if the component is enabled

Specified by:
isEnabled in class AbstractBComponent
Returns:
true if the component is enabled

setView

public void setView(View view)
Set the components primary view. This method effectively removes any other views and binds the component to the newly specified view.

Specified by:
setView in class AbstractBComponent
Parameters:
view - the view to which this component is bound

addView

public void addView(View view)
Bind a component to a view

Specified by:
addView in class AbstractBComponent
Parameters:
view - the view to which this component is bound

removeView

public boolean removeView(View view)
Remove a view from this component

Specified by:
removeView in class AbstractBComponent
Returns:
true if we were able to remove the view from the component

removeAllViews

public void removeAllViews()
Remove all views from this component

Specified by:
removeAllViews in class AbstractBComponent

getViews

public List getViews()
Get a list of all the views for this component. This returns a copy of the underlying view list.

Specified by:
getViews in class AbstractBComponent
Returns:
a List of all the views for this component

getFirstView

protected View getFirstView()

setAttr

public void setAttr(Object attr,
                    Object val)
set an attribute for this particular component. When the component is rendered, component attributes will be shown as element attributes in the elements that back each of the views associated with this component. This means that if you set an attribute for the component, it will affect all views associated with the component.If you wish to set an attribute for a specific view alone, then you should get the view, find the node that backs it, and then set the attribute manually that way.

Specified by:
setAttr in class AbstractBComponent
Parameters:
attr - the attribute name
val - the attribute value

getAttr

public Object getAttr(Object attr)
get an attribute associated with this particular component. Note that the attribute map that backs this method only keeps tracks of specific attributes you have added to the component. It does not look at attributes that are physically associated with the underlying elements that back each of the views associated with this component. What this means is that if the template that backs a view has some attribute "foo" and you try to see the value of that attribute using this method, you will not be able to find it unless you have actually associated an attribute named "foo" with the specific component.

Specified by:
getAttr in class AbstractBComponent
Parameters:
attr - the attribute name
Returns:
the value for the given attribute (may be null)

getAttrMap

public Map getAttrMap()
get a copy of the underlying component attribute Map

Specified by:
getAttrMap in class AbstractBComponent
Returns:
a copy of the underlying component attribute Map

setRenderStrategy

public void setRenderStrategy(RenderStrategy irs)
Set the render strategy for this component and all its children. Valid values include:

getRenderStrategy

public RenderStrategy getRenderStrategy()
Get the render strategy for this component

Returns:
the render strategy for this component

render

public void render(ViewContext vc)
            throws RenderException
Render the component for a view with the specified ViewContext. You shouldn't override this method unless you really know what you're doing...

Specified by:
render in class AbstractBComponent
Parameters:
vc - ViewContext for the client view
Throws:
RenderException - if the particular View cannot be rendered

render

protected void render(ViewContext vc,
                      int depth)
               throws RenderException
Throws:
RenderException

preRender

protected void preRender(ViewContext vc,
                         int depth)
Prep phase before rendering. This is typically where you would put any pre-rendering specific logic.


renderView

protected final void renderView(View view,
                                ViewContext vc)
                         throws RenderException
Render a specific view for the component.

Parameters:
view - View to be rendered
vc - ViewContext for the client view
Throws:
RenderException - if the particular View cannot be rendered

renderView

protected void renderView(View view,
                          ViewContext vc,
                          int depth)
                   throws RenderException
Throws:
RenderException

postRender

protected void postRender(ViewContext vc,
                          int depth)
Cleanup after rendering. This method is guaranteed to be invoked, even if there is an error during rendering. This is typically where you would put any custom post-rendering cleanup.


supports

public boolean supports(ViewContext vc)
Determine if a specific ViewContext is supported by this component

Specified by:
supports in class AbstractBComponent
Parameters:
vc - ViewContext for the client view
Returns:
true if the specified ViewCapabilites are supported


Copyright © 2003 BarracudaMVC.org All Rights Reserved.