org.enhydra.barracuda.core.comp.scripting
Class BScript

java.lang.Object
  |
  +--org.enhydra.barracuda.core.comp.AbstractBComponent
        |
        +--org.enhydra.barracuda.core.comp.BComponent
              |
              +--org.enhydra.barracuda.core.comp.scripting.BScript
All Implemented Interfaces:
BContainer, StateMap

public class BScript
extends BComponent

BScript is used to attach a javascript command to a DOM element attribute.

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
static int APPEND
           
protected  java.lang.String jsattr
           
protected  java.lang.String jscmd
           
protected static org.apache.log4j.Logger logger
           
protected  int mode
           
static java.lang.String ON_BLUR
           
static java.lang.String ON_CHANGE
           
static java.lang.String ON_CLICK
           
static java.lang.String ON_DBL_CLICK
           
static java.lang.String ON_FOCUS
           
static java.lang.String ON_KEY_DOWN
           
static java.lang.String ON_KEY_PRESS
           
static java.lang.String ON_KEY_UP
           
static java.lang.String ON_LOAD
           
static java.lang.String ON_MOUSE_DOWN
           
static java.lang.String ON_MOUSE_MOVE
           
static java.lang.String ON_MOUSE_OUT
           
static java.lang.String ON_MOUSE_OVER
           
static java.lang.String ON_MOUSE_UP
           
static java.lang.String ON_RESET
           
static java.lang.String ON_SELECT
           
static java.lang.String ON_SUBMIT
           
static java.lang.String ON_UNLOAD
           
static int PREPEND
           
static int REPLACE
           
protected  java.util.List resources
           
 
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
BScript()
          Public noargs constructor
BScript(java.lang.String jsattr, java.lang.String jscmd)
          Public constructor which creates the component.
BScript(java.lang.String jsattr, java.lang.String jscmd, int mode)
          Public constructor which creates the component.
BScript(java.lang.String jsattr, java.lang.String jscmd, int mode, java.lang.String resource)
          Public constructor which creates the component.
 
Method Summary
 void addResource(java.lang.String resource)
          Add a script resource (resources specified will automatically create BScriptResource delegates at render time)
 java.lang.String getAttr()
          Get the JavaScript attr the command is be bound to
 java.lang.String getCmd()
          Get the JavaScript command for this particular component
 int getMode()
          Get the replacement mode for this script
 java.util.List getResources()
          Get a list of script resource
 void removeResource(java.lang.String resource)
          Remove a script resource
 void setAttr(java.lang.String ijsattr)
          Specify the JavaScript attr the command should be bound to
 void setCmd(java.lang.String ijscmd)
          Set the JavaScript command for this particular component
 void setMode(int imode)
          Set the mode for the action (defaults to REPLACE).
 java.lang.String toString()
          Get a String representation of the component
 
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, 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

REPLACE

public static final int REPLACE
See Also:
Constant Field Values

PREPEND

public static final int PREPEND
See Also:
Constant Field Values

APPEND

public static final int APPEND
See Also:
Constant Field Values

ON_CLICK

public static final java.lang.String ON_CLICK
See Also:
Constant Field Values

ON_DBL_CLICK

public static final java.lang.String ON_DBL_CLICK
See Also:
Constant Field Values

ON_MOUSE_DOWN

public static final java.lang.String ON_MOUSE_DOWN
See Also:
Constant Field Values

ON_MOUSE_UP

public static final java.lang.String ON_MOUSE_UP
See Also:
Constant Field Values

ON_MOUSE_OVER

public static final java.lang.String ON_MOUSE_OVER
See Also:
Constant Field Values

ON_MOUSE_MOVE

public static final java.lang.String ON_MOUSE_MOVE
See Also:
Constant Field Values

ON_MOUSE_OUT

public static final java.lang.String ON_MOUSE_OUT
See Also:
Constant Field Values

ON_KEY_PRESS

public static final java.lang.String ON_KEY_PRESS
See Also:
Constant Field Values

ON_KEY_DOWN

public static final java.lang.String ON_KEY_DOWN
See Also:
Constant Field Values

ON_KEY_UP

public static final java.lang.String ON_KEY_UP
See Also:
Constant Field Values

ON_LOAD

public static final java.lang.String ON_LOAD
See Also:
Constant Field Values

ON_UNLOAD

public static final java.lang.String ON_UNLOAD
See Also:
Constant Field Values

ON_FOCUS

public static final java.lang.String ON_FOCUS
See Also:
Constant Field Values

ON_BLUR

public static final java.lang.String ON_BLUR
See Also:
Constant Field Values

ON_SELECT

public static final java.lang.String ON_SELECT
See Also:
Constant Field Values

ON_CHANGE

public static final java.lang.String ON_CHANGE
See Also:
Constant Field Values

ON_SUBMIT

public static final java.lang.String ON_SUBMIT
See Also:
Constant Field Values

ON_RESET

public static final java.lang.String ON_RESET
See Also:
Constant Field Values

jscmd

protected java.lang.String jscmd

jsattr

protected java.lang.String jsattr

mode

protected int mode

resources

protected java.util.List resources
Constructor Detail

BScript

public BScript()
Public noargs constructor


BScript

public BScript(java.lang.String jsattr,
               java.lang.String jscmd)
Public constructor which creates the component. When rendered, it will take the specified command and REPLACE it in the target scripting attribute

You should generally only use this constructor when returning BScript from a Model, as the model components will automatically bind the component to a view for you. If you use this constructor in some other situation, you should manually bind the component to the proper view.

Parameters:
jsattr - the target script attribute
jscmd - the script command

BScript

public BScript(java.lang.String jsattr,
               java.lang.String jscmd,
               int mode)
Public constructor which creates the component. When rendered, it will take the specified command and render it in the target scripting attribute, using the specified replacement mode.

Parameters:
jsattr - the target script attribute
jscmd - the script command
mode - the cmd replacement mode (REPLACE, PREPEND, or APPEND)

BScript

public BScript(java.lang.String jsattr,
               java.lang.String jscmd,
               int mode,
               java.lang.String resource)
Public constructor which creates the component. When rendered, it will take the specified command and render it in the target scripting attribute, using the specified replacement mode.

Parameters:
jsattr - the target script attribute
jscmd - the script command
mode - the cmd replacement mode (REPLACE, PREPEND, or APPEND)
resource - any necessary resource scripts
Method Detail

setAttr

public void setAttr(java.lang.String ijsattr)
Specify the JavaScript attr the command should be bound to


getAttr

public java.lang.String getAttr()
Get the JavaScript attr the command is be bound to

Returns:
the JavaScript attr the command is be bound to

setCmd

public void setCmd(java.lang.String ijscmd)
Set the JavaScript command for this particular component


getCmd

public java.lang.String getCmd()
Get the JavaScript command for this particular component

Returns:
the JavaScript command for this particular component

setMode

public void setMode(int imode)
Set the mode for the action (defaults to REPLACE). In most cases, you will simply REPLACE whatever the current cmd is in the template. Sometimes, however, you may want to keep what's already there. In such a situation, you would specify either APPEND (tack it on to what's already there) or PREPEND (stick it in front of what's there)


getMode

public int getMode()
Get the replacement mode for this script

Returns:
the replacement mode for this script

addResource

public void addResource(java.lang.String resource)
Add a script resource (resources specified will automatically create BScriptResource delegates at render time)


removeResource

public void removeResource(java.lang.String resource)
Remove a script resource


getResources

public java.util.List getResources()
Get a list of script resource

Returns:
a list of script resources

toString

public java.lang.String toString()
Get a String representation of the component

Overrides:
toString in class AbstractBComponent
Returns:
a String representation of the component


Copyright © 2001 Enhydra.org