Expresso 5-6

com.jcorporate.expresso.ext.struts.taglib
Class ControllerUtils

java.lang.Object
  extended bycom.jcorporate.expresso.ext.struts.taglib.ControllerUtils

public final class ControllerUtils
extends Object

Utilities for use by the extended "expresso-aware" Struts tags

Author:
Michael P. Nash

Constructor Summary
ControllerUtils()
           
 
Method Summary
static boolean exists(PageContext pageContext, String name, String property)
          Determines if the defined name and property combination exists in the ControllerResponse for the page context
static ControllerElement findElement(PageContext pageContext, String name, String property)
          Finds a controller element specified by name and/or property
static Input findInput(PageContext pageContext, String property)
          Find an input out of the ControllerReponse
static Transition findTransition(PageContext pageContext, String property)
          Locate and return the transition named by the specified property
static String getBeanProperty(PageContext pageContext, String name, String property, boolean ignore)
          

We interpret property names as follows: A "normal" name (e.g. no special characters) should represent the contents of an output object.

static ControllerResponse getResponse(PageContext pageContext)
          Get the current ControllerResponse object from the session
static String getSpecificBeanProperty(PageContext pageContext, String name, String property, boolean ignore)
          Get a property from a specific ControllerElement stored as a bean in the current page
static ControllerElement interpretLeadElement(PageContext pageContext, String beanExpr)
          Inteprets the lead argument for InputTag expression where the bean expression is a scope for the type of controller that should be retrieved from the ControllerResponse.
static String nestedProperty(PageContext pageContext, String name, String property)
          Deprecated. use nestedProperty(PageContext, name, property, checkExists) instead
static String nestedProperty(PageContext pageContext, String name, String property, boolean checkExists)
          If we were asked for a property that contains a "/", then we're referring to either a property of or a value of a "nested" property
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControllerUtils

public ControllerUtils()
Method Detail

getBeanProperty

public static String getBeanProperty(PageContext pageContext,
                                     String name,
                                     String property,
                                     boolean ignore)
                              throws JspException

We interpret property names as follows: A "normal" name (e.g. no special characters) should represent the contents of an output object. If there is no such output, it's an error. A name with "/" delimiters in it indicates a "nested" property. The "final" name in the path is the name of the property we are after. A name containing "." indicates a property of an input or output (we look for inputs first, then outputs).

Note that the parameter ignore is not actually used and will be removed in future versions

Parameters:
pageContext - the JSP page context
name - the name of the bean to retrieve
property - the name of the bean property to retrieve
ignore - Ignore errors and return null if the bean property isn't found?
Returns:
java.lang.String representing the specific bean property
Throws:
JspException - upon error

getResponse

public static final ControllerResponse getResponse(PageContext pageContext)
Get the current ControllerResponse object from the session

Parameters:
pageContext - the jsp page context
Returns:
a ControllerResponse generated from the page.

getSpecificBeanProperty

public static String getSpecificBeanProperty(PageContext pageContext,
                                             String name,
                                             String property,
                                             boolean ignore)
                                      throws JspException
Get a property from a specific ControllerElement stored as a bean in the current page

Parameters:
pageContext - the JSP page context
name - the name of the bean to retrieve
property - the name of the bean property to retrieve
ignore - Unused and to be removed in a future release
Returns:
java.lang.String representing the specific bean property
Throws:
JspException - upon error

exists

public static boolean exists(PageContext pageContext,
                             String name,
                             String property)
                      throws JspException
Determines if the defined name and property combination exists in the ControllerResponse for the page context

Parameters:
pageContext - The Jsp Page Context to retrieve the ControllerResponse from
name - The name of the bean to be searching for. If not null then we're looking for a bean other than ControllerReponse
property - The name of the property (possibly nested) to retrieve
Returns:
true if the system can find the defined element
Throws:
JspException - on issues like Type Mismatches.

interpretLeadElement

public static ControllerElement interpretLeadElement(PageContext pageContext,
                                                     String beanExpr)
                                              throws ControllerException
Inteprets the lead argument for InputTag expression where the bean expression is a scope for the type of controller that should be retrieved from the ControllerResponse.

The bean expression is a string, which must be formatted as "<ELEMENT-SCOPE> : <ELEMENT-NAME>".

Where ELEMENT-SCOPE is a string member of block, input, output, and transition.
The ELEMENT-NAME specifies the name of the controller element to retrieve.

Here is an example of what we are trying to achieve with this method. This is taken from the eForum:

 <html:textarea name="block:optionsBlock" 
      property="/signature" cols="80" rows="6" />
 

IDEA: Should this method support nested controller elements

Parameters:
pageContext - the page context
beanExpr - the bean expression
Returns:
ControllerElement the controller element
Throws:
ControllerException - if problem occurs retrieving the element

findElement

public static ControllerElement findElement(PageContext pageContext,
                                            String name,
                                            String property)
Finds a controller element specified by name and/or property

Parameters:
pageContext - The jsp page context
name - the name of the bean to get. may be null if we're looking for top level controller elements.
property - the property to retrieve. If we have both a name AND a property, then the property must start with a "/" and then each successive forward slash indicates walking through nested controller elements until we find what we're looking for.
Returns:
ControllerElement or null.

findInput

public static Input findInput(PageContext pageContext,
                              String property)
                       throws JspException
Find an input out of the ControllerReponse

Parameters:
pageContext -
property -
Returns:
Throws:
JspException

findTransition

public static Transition findTransition(PageContext pageContext,
                                        String property)
                                 throws JspException
Locate and return the transition named by the specified property

Throws:
JspException

nestedProperty

public static String nestedProperty(PageContext pageContext,
                                    String name,
                                    String property)
                             throws JspException
Deprecated. use nestedProperty(PageContext, name, property, checkExists) instead

If we were asked for a property that contains a "/", then we're referring to either a property of or a value of a "nested" property

Parameters:
pageContext -
name -
property -
Returns:
the requested property
Throws:
JspException

nestedProperty

public static String nestedProperty(PageContext pageContext,
                                    String name,
                                    String property,
                                    boolean checkExists)
                             throws JspException
If we were asked for a property that contains a "/", then we're referring to either a property of or a value of a "nested" property

Parameters:
pageContext -
name -
property -
checkExists -
Returns:
the requested property
Throws:
JspException

Expresso 5-6

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