Expresso 5-6

com.jcorporate.expresso.core.controller
Class Block

java.lang.Object
  extended bycom.jcorporate.expresso.core.controller.ControllerElement
      extended bycom.jcorporate.expresso.core.controller.Block
All Implemented Interfaces:
Cloneable, Serializable

public class Block
extends ControllerElement
implements Cloneable, Serializable

A Block is a logical grouping of Expresso Controller Elements used for nesting.

Recognized Types:

The following types are recognized by the expresso framework and automatically rendered: You may add your own types or ignore them if you are doing your own page rendering.

header-row: Renders each subobject in it's own cell with the appropriate jc-header class Make the cells pipe-delimited strings

row: Renders all subobjects in one row

borderWidth: Renders the table width a paricular border.

default behavior: Render as a table/nested table.

Author:
Shash Chatterjee
See Also:
Serialized Form

Constructor Summary
Block()
          Instantiation Constructor.
Block(String newName)
          Convenience constructor - to make a new Block object with a specific name.
 
Method Summary
 void add(ControllerElement element)
          Add an element to this Block
 Object clone()
          Generate a copy of this current Block
static ControllerElement fromXML(org.w3c.dom.Node n)
          Return a controller element based upon the xml fragment
 Block getBlock(String blockName)
          Retrieve a newsted Block by name.
 Vector getBlocks()
          Retrieve a list of blocks contained within this Block
 String getFormEncoding()
          Retrieve the form encoding attribute of this block
 String getFormMethod()
          Get the form method whether GET or POST
 Transition getFormTransition()
          Get the Form Transition
 Input getInput(String inputName)
          Retrieve a nested input by name.
 Vector getInputs()
          Get the nested Inputs
 Map getNamedBlocks()
          Retrieve the Blocks as a map so that JSTL can cope with navigating the ControllerResponse through a named fashion
 Map getNamedInputs()
          Retrieve the inputs as a map so that JSTL can cope with navigating the ControllerResponse through a named fashion
 Map getNamedOutputs()
          Retrieve the outputs as a map so that JSTL can cope with navigating the ControllerResponse through a named fashion
 Map getNamedTransitions()
          Retrieve the transitions as a map so that JSTL can cope with navigating the ControllerResponse through a named fashion
 int getNumContents()
          Get the number of elements contained within the nested block
 Output getOutput(String outputName)
          Retrieve a nested output by name.
 Vector getOutputs()
          Retrieve a list of Outputs nested wtihin this block
 Transition getTransition(String transitionName)
          Retrieve a nested transition by name.
 Vector getTransitions()
          Retrieve a list of Transitions nested wtihin this block
 boolean isForm()
          Return true if the form attribute for this block has been set
 void removeNested(ControllerElement elementToRemove)
          Remove an element from the nested elements for this item
 void setForm(String isForm)
          Set whether this form is true or not.
 void setFormEncoding(String encoding)
          Set the encoding attribute for the block form
 void setFormMethod(String method)
          Set the form method.
 void setFormTransition(Transition a)
          Sets the form transition
protected  FastStringBuffer toNestedXML(FastStringBuffer stream, String blockLabel, Vector elements)
           
 FastStringBuffer toXML(FastStringBuffer stream)
          Concert the object to an xml fragment.
 
Methods inherited from class com.jcorporate.expresso.core.controller.ControllerElement
addNested, allNested, fromXML, getAttribute, getAttributes, getAttributesOrNull, getContent, getContents, getControllerResponse, getDescription, getDisplayLength, getLabel, getLines, getName, getNested, getNested, getNestedCount, getNestedIterator, getNestedMap, getNestedOrNull, getParent, getTitle, getType, remove, setAttribute, setControllerResponse, setDescription, setDisplayLength, setLabel, setLines, setName, setParent, setType
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Block

public Block()
Instantiation Constructor. Normally not called


Block

public Block(String newName)
Convenience constructor - to make a new Block object with a specific name.

Parameters:
newName - The new name of the block
Method Detail

add

public void add(ControllerElement element)
Add an element to this Block

Parameters:
element - an element to be added

getNamedTransitions

public Map getNamedTransitions()
Retrieve the transitions as a map so that JSTL can cope with navigating the ControllerResponse through a named fashion

Returns:
java.util.Map map of transitions which have been added

getNamedOutputs

public Map getNamedOutputs()
Retrieve the outputs as a map so that JSTL can cope with navigating the ControllerResponse through a named fashion

Returns:
java.util.Map map of outputs which have been added

getNamedInputs

public Map getNamedInputs()
Retrieve the inputs as a map so that JSTL can cope with navigating the ControllerResponse through a named fashion

Returns:
java.util.Map map of inputs which have been added

getNamedBlocks

public Map getNamedBlocks()
Retrieve the Blocks as a map so that JSTL can cope with navigating the ControllerResponse through a named fashion

Returns:
java.util.Map map of blocks which have been added

removeNested

public void removeNested(ControllerElement elementToRemove)
                  throws ControllerException
Remove an element from the nested elements for this item

Overrides:
removeNested in class ControllerElement
Parameters:
elementToRemove - The element to be removed from the list of nested items.
Throws:
ControllerException - if there is no such item nested in this item

clone

public Object clone()
             throws CloneNotSupportedException
Generate a copy of this current Block

Overrides:
clone in class ControllerElement
Returns:
an instantiated Block onbject
Throws:
CloneNotSupportedException - as per the API spec.

fromXML

public static ControllerElement fromXML(org.w3c.dom.Node n)
                                 throws ControllerException
Return a controller element based upon the xml fragment

Parameters:
n - a DOM Node that we extract the internal elements
Returns:
an instantiated ControllerElement [specifically a block]
Throws:
ControllerException - if unable to build itself from the DOM node

getBlocks

public Vector getBlocks()
Retrieve a list of blocks contained within this Block

Returns:
java.util.Vector

getBlock

public Block getBlock(String blockName)
Retrieve a newsted Block by name. Note that for this to work correctly, all added items in the block MUST have unique names. otherwise, you may get ClassCastExceptions

Parameters:
blockName - the name of the block to retrieve
Returns:
Block or null if the subBlock doesn't exit

getInput

public Input getInput(String inputName)
Retrieve a nested input by name. Note that for this to work correctly, all added items in the block MUST have unique names. otherwise, you may get ClassCastExceptions

Parameters:
inputName - the name of the block to retrieve
Returns:
Input or null if the sub input doesn't exit

getOutput

public Output getOutput(String outputName)
Retrieve a nested output by name. Note that for this to work correctly, all added items in the block MUST have unique names. otherwise, you may get ClassCastExceptions

Parameters:
outputName - the name of the block to retrieve
Returns:
Output or null if the sub output doesn't exit

getTransition

public Transition getTransition(String transitionName)
Retrieve a nested transition by name. Note that for this to work correctly, all added items in the block MUST have unique names. otherwise, you may get ClassCastExceptions

Parameters:
transitionName - the name of the block to retrieve
Returns:
Transition or null if the sub Transition doesn't exit

getFormEncoding

public String getFormEncoding()
Retrieve the form encoding attribute of this block

Returns:
java.lang.String or null

getFormMethod

public String getFormMethod()
Get the form method whether GET or POST

Returns:
java.lang.String either GET or POST

getFormTransition

public Transition getFormTransition()
Get the Form Transition

Returns:
com.jcorporate.expresso.core.controller.Transition

getInputs

public Vector getInputs()
Get the nested Inputs

Returns:
java.util.Vector of Inputs

getNumContents

public int getNumContents()
Get the number of elements contained within the nested block

Returns:
integer describing the size of the nested contents

getOutputs

public Vector getOutputs()
Retrieve a list of Outputs nested wtihin this block

Returns:
java.util.Vector of nested Outputs

getTransitions

public Vector getTransitions()
Retrieve a list of Transitions nested wtihin this block

Returns:
java.util.Vector of nested Transitions

isForm

public boolean isForm()
Return true if the form attribute for this block has been set

Returns:
boolean true if the attribute form has been set to true for this block

setForm

public void setForm(String isForm)
             throws ControllerException
Set whether this form is true or not.

Parameters:
isForm - either 'true' or 'false' (lower case)
Throws:
ControllerException - if the methods are invalid

setFormEncoding

public void setFormEncoding(String encoding)
                     throws ControllerException
Set the encoding attribute for the block form

Parameters:
encoding - java.lang.String
Throws:
ControllerException - if the attribute is unable to be thrown

setFormMethod

public void setFormMethod(String method)
                   throws ControllerException
Set the form method.

Parameters:
method - The string get or post (lower case)
Throws:
ControllerException - upon invalid argument

setFormTransition

public void setFormTransition(Transition a)
                       throws ControllerException
Sets the form transition

Parameters:
a - a Transition that is the equiv of the 'submit' button on the form.
Throws:
ControllerException - if the transition is null

toXML

public FastStringBuffer toXML(FastStringBuffer stream)
Concert the object to an xml fragment.

Overrides:
toXML in class ControllerElement
Parameters:
stream - an instantiated FastStringBuffer to which we are supposed to append to.
Returns:
a fleshed out FastStringBuffer (usually the stream parameter)

toNestedXML

protected FastStringBuffer toNestedXML(FastStringBuffer stream,
                                       String blockLabel,
                                       Vector elements)

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.