org.enhydra.barracuda.core.comp
Class BAction

java.lang.Object
  |
  +--org.enhydra.barracuda.core.comp.AbstractBComponent
        |
        +--org.enhydra.barracuda.core.comp.BComponent
              |
              +--org.enhydra.barracuda.core.comp.BAction
All Implemented Interfaces:
BContainer, StateMap
Direct Known Subclasses:
BLink

public class BAction
extends BComponent

A BAction component is a component that you can use to catch client side events. It can be used to render <a>, <form>, <button>, <input>, and <select> elements. It allow you to specify a specific action to be generated, or can simply default to what's in the template markup. You can also add event listeners directly to the component, and only those particular listeners will be notified when the event actually occurs on the client.

In most cases you will not actually need to bind the component to a view in order to use it--if you return it from a model, this will be done for you automatically. If however, you intend to use the component standalone (ie. manually attaching it to a specific node in the DOM) or inline (ie. in a toString()), then you MUST BIND IT TO A VIEW before rendering, or an error will be generated.


Field Summary
protected  ControlEvent actionEvent
           
protected  java.lang.String actionUrl
           
protected  boolean disableBackButton
           
protected  java.util.List listeners
           
protected static org.apache.log4j.Logger logger
           
 
Fields inherited from class org.enhydra.barracuda.core.comp.BComponent
attrs, CACHING_MARKER, enabled, name, rs, VISIBILITY_MARKER, visible
 
Fields inherited from class org.enhydra.barracuda.core.comp.AbstractBComponent
children, dvc, isStepChild, parent, preventCaching, statemap, stepChildren, tempViews, validated, views
 
Constructor Summary
BAction()
          Public noargs constructor
BAction(ControlEvent actionEvent)
          Public constructor which creates the component and binds it to a view.
BAction(java.lang.String actionUrl)
          Public constructor which creates the component and binds it to a view.
 
Method Summary
 void addEventListener(ListenerFactory lf)
          Add an event listener to this component.
 java.lang.String getAction(ViewContext vc)
          Get the action to be fired by this component.
 java.lang.String getAction(ViewContext vc, boolean preventRewriting)
          Get the action to be fired by this component.
 boolean getDisableBackButton()
          Get disable back button
 java.util.Map getParams()
          Get any associated params
 void removeEventListener(ListenerFactory lf)
          Remove an event listener from this component
 void setAction(ControlEvent iactionEvent)
          Set the action to be fired by this component.
 void setAction(java.lang.String iactionUrl)
          Set the action to be fired by this component.
 void setDisableBackButton(boolean idisableBackButton)
          Set disable back button (only works if your client supports Javascript)
 void setParam(java.lang.String key, java.lang.String val)
          Set any associated params
 void setParam(java.lang.String key, java.lang.String[] val)
          Set any associated list of params
 
Methods inherited from class org.enhydra.barracuda.core.comp.BComponent
addView, getAttr, getAttrMap, getFirstView, getName, getRenderStrategy, getViews, isEnabled, isVisible, postRender, preRender, removeAllViews, removeView, render, render, renderView, renderView, setAttr, setEnabled, setEnabled, setName, setRenderStrategy, setView, setVisible, setVisible, supports
 
Methods inherited from class org.enhydra.barracuda.core.comp.AbstractBComponent
addChild, addStepChild, addStepChild, addTempView, destroyCycle, findComponentMap, findRendererFactory, getChild, getChildren, getDefaultViewContext, getParent, getPreventCaching, getRenderer, getRenderer, getRootComponent, getState, getStateKeys, getStateValues, hasChildren, hasViews, initCycle, installRendererFactory, invalidate, isStepChild, printStackTrace, printStackTrace, printStackTrace, putState, removeAll, removeAllStepChildren, removeChild, removeChild, removeState, setDefaultViewContext, setParent, setPreventCaching, 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 org.apache.log4j.Logger logger

actionEvent

protected ControlEvent actionEvent

actionUrl

protected java.lang.String actionUrl

listeners

protected java.util.List listeners

disableBackButton

protected boolean disableBackButton
Constructor Detail

BAction

public BAction()
Public noargs constructor


BAction

public BAction(java.lang.String actionUrl)
Public constructor which creates the component and binds it to a view. Also allows you to specify that a custom url be fired.

Parameters:
actionUrl - the action url to be fired

BAction

public BAction(ControlEvent actionEvent)
Public constructor which creates the component and binds it to a view. Also allows you to specify that a custom event be fired.

Parameters:
actionEvent - the action event to be fired
Method Detail

setAction

public void setAction(java.lang.String iactionUrl)
Set the action to be fired by this component.


setAction

public void setAction(ControlEvent iactionEvent)
Set the action to be fired by this component.


getAction

public java.lang.String getAction(ViewContext vc)
Get the action to be fired by this component. The action will either be the URL or the Event that backs this component

Parameters:
vc - the ViewContext that determines the context of the action
Returns:
a string representing the action to be fired by this component

getAction

public java.lang.String getAction(ViewContext vc,
                                  boolean preventRewriting)
Get the action to be fired by this component. The action will either be the URL or the Event that backs this component

Parameters:
vc - the ViewContext that determines the context of the action
preventRewriting - this should be set to true only if you want to prevent URLRewriting from taking place. As a developer, you will probably never need to do this, unless to need to further modify the action prior to finally encoding it (HTMLActionRenderer does this)
Returns:
a string representing the action to be fired by this component

setParam

public void setParam(java.lang.String key,
                     java.lang.String val)
Set any associated params


setParam

public void setParam(java.lang.String key,
                     java.lang.String[] val)
Set any associated list of params


getParams

public java.util.Map getParams()
Get any associated params


setDisableBackButton

public void setDisableBackButton(boolean idisableBackButton)
Set disable back button (only works if your client supports Javascript)


getDisableBackButton

public boolean getDisableBackButton()
Get disable back button

Returns:
true if we want the back button disabled

addEventListener

public void addEventListener(ListenerFactory lf)
Add an event listener to this component.

Parameters:
lf - the event listener to be added

removeEventListener

public void removeEventListener(ListenerFactory lf)
Remove an event listener from this component

Parameters:
lf - the event listener to be removed


Copyright © 2001 Enhydra.org