org.barracudamvc.core.comp
Class BComponent

java.lang.Object
  extended by org.barracudamvc.core.comp.AbstractBComponent
      extended by org.barracudamvc.core.comp.BComponent
All Implemented Interfaces:
Attrs, BContainer, StateMap
Direct Known Subclasses:
BAction, BImage, BInput, BLabel, 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
static String DEFAULT_ENCODING
           
protected  boolean enabled
           
protected  String enc
           
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.barracudamvc.core.comp.AbstractBComponent
attrs, children, dvc, isStepChild, parent, statemap, stepChildren, tempViews, validated, views
 
Constructor Summary
BComponent()
           
 
Method Summary
 BComponent addView(View view)
          Bind a component to a view
protected  String decodeStr(String s)
          Actually decode a string based on the current encoding - note that we eat any acceptions that get thrown; if they occur we simply re-encode using UTF-8
protected  String encodeStr(String s)
          Actually encode a string based on the current encoding - note that we eat any acceptions that get thrown; if they occur we simply re-encode using UTF-8
 String getEncoding()
          Get the encoding for this component.
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.
 BComponent removeAllViews()
          Remove all views from this component
 boolean removeView(View view)
          Remove a view from this component
 BComponent 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)
           
 BComponent setEnabled(boolean val)
          Enable/disable the component
 BComponent setEnabled(boolean val, boolean recurse)
          Enable/disable the component recursively
 void setEncoding(String ienc)
          Set the encoding for this component (and all children, unless they specifically specify a different encoding).
 BContainer setName(String iname)
          Set the name for this component.
 BComponent setRenderStrategy(RenderStrategy irs)
          Set the render strategy for this component and all its children.
 BComponent setView(View view)
          Set the components primary view.
 BComponent setVisible(boolean val)
          Set the component visibility
 BComponent 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.barracudamvc.core.comp.AbstractBComponent
addChild, addStepChild, addStepChild, addTempView, clearState, destroyCycle, findComponentMap, findRendererFactory, getAttr, getAttrMap, getChild, getChildren, getDefaultViewContext, getParent, getRenderer, getRenderer, getRendererFactory, getRootComponent, getState, getStateKeys, getStateStore, hasChildren, hasViews, initCycle, installRendererFactory, invalidate, isStepChild, printStackTrace, printStackTrace, printStackTrace, putState, removeAll, removeAllStepChildren, removeChild, removeChild, removeState, setAttr, 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

DEFAULT_ENCODING

public static String DEFAULT_ENCODING

name

protected String name

visible

protected boolean visible

enabled

protected boolean enabled

rs

protected RenderStrategy rs

enc

protected String enc
Constructor Detail

BComponent

public BComponent()
Method Detail

setName

public BContainer 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 BComponent setVisible(boolean val)
Set the component visibility

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

setVisible

public BComponent 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 BComponent setEnabled(boolean val)
Enable/disable the component

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

setEnabled

public BComponent 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

setEncoding

public void setEncoding(String ienc)
Set the encoding for this component (and all children, unless they specifically specify a different encoding). Defaults to DEFAULT_ENCODING

Parameters:
enc - the encoding for this component (null = look to parent)

getEncoding

public String getEncoding()
Get the encoding for this component. If null, look to parent. If parent is null, default to DEFAULT_ENCODING

Returns:
the encoding for this component

encodeStr

protected String encodeStr(String s)
Actually encode a string based on the current encoding - note that we eat any acceptions that get thrown; if they occur we simply re-encode using UTF-8


decodeStr

protected String decodeStr(String s)
Actually decode a string based on the current encoding - note that we eat any acceptions that get thrown; if they occur we simply re-encode using UTF-8


setView

public BComponent 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 BComponent 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 BComponent 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()

setRenderStrategy

public BComponent 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 BComponent 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 © 2006 BarracudaMVC.org All Rights Reserved.