Save This Page
Home » struts-2.1.8.1-src » org.apache » struts2 » components » [javadoc | source]
org.apache.struts2.components
public class: Component [javadoc | source]
java.lang.Object
   org.apache.struts2.components.Component
Base class to extend for UI components.

This class is a good extension point when building reuseable UI components.
Field Summary
public static final  String COMPONENT_STACK     
protected  ValueStack stack     
protected  Map parameters     
protected  ActionMapper actionMapper     
protected  boolean throwExceptionOnELFailure     
Constructor:
 public Component(ValueStack stack) 
    Constructor.
    Parameters:
    stack - OGNL value stack.
Method from org.apache.struts2.components.Component Summary:
addAllParameters,   addParameter,   altSyntax,   altSyntax,   completeExpressionIfAltSyntax,   copyParams,   determineActionURL,   determineNamespace,   end,   end,   fieldError,   findAncestor,   findString,   findString,   findStringIfAltSyntax,   findValue,   findValue,   findValue,   getComponentStack,   getParameters,   getStack,   popComponentStack,   setActionMapper,   setThrowExceptionsOnELFailure,   start,   stripExpressionIfAltSyntax,   stripExpressionIfAltSyntax,   toString,   usesBody
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.components.Component Detail:
 public  void addAllParameters(Map params) 
    Adds all the given parameters to this component's own parameters.
 public  void addParameter(String key,
    Object value) 
    Adds the given key and value to this component's own parameter.

    If the provided key is null nothing happens. If the provided value is null any existing parameter with the given key name is removed.

 public boolean altSyntax() 
    Is the altSyntax enabled? [TRUE]

    See struts.properties where the altSyntax flag is defined.

 public static boolean altSyntax(ValueStack stack) 
    Is the altSyntax enabled? [TRUE]

 protected String completeExpressionIfAltSyntax(String expr) 
    Adds the sorrounding %{ } to the expression for proper processing.
 public  void copyParams(Map params) 
    Pushes this component's parameter Map as well as the component itself on to the stack and then copies the supplied parameters over. Because the component's parameter Map is pushed before the component itself, any key-value pair that can't be assigned to componet will be set in the parameters Map.
 protected String determineActionURL(String action,
    String namespace,
    String method,
    HttpServletRequest req,
    HttpServletResponse res,
    Map parameters,
    String scheme,
    boolean includeContext,
    boolean encodeResult,
    boolean forceAddSchemeHostAndPort,
    boolean escapeAmp) 
 protected String determineNamespace(String namespace,
    ValueStack stack,
    HttpServletRequest req) 
    Determines the namespace of the current page being renderdd. Useful for Form, URL, and href generations.
 public boolean end(Writer writer,
    String body) 
    Callback for the end tag of this component. Should the body be evaluated again?

    NOTE: will pop component stack.

 protected boolean end(Writer writer,
    String body,
    boolean popComponentStack) 
    Callback for the start tag of this component. Should the body be evaluated again?

    NOTE: has a parameter to determine to pop the component stack.

 protected StrutsException fieldError(String field,
    String errorMsg,
    Exception e) 
    Constructs a RuntimeException based on the given information.

    A message is constructed and logged at ERROR level before being returned as a RuntimeException.

 protected Component findAncestor(Class clazz) 
    Finds the nearest ancestor of this component stack.
 protected String findString(String expr) 
    Evaluates the OGNL stack to find a String value.
 protected String findString(String expr,
    String field,
    String errorMsg) 
    Evaluates the OGNL stack to find a String value.

    If the given expression is null a error is logged and a RuntimeException is thrown constructed with a messaged based on the given field and errorMsg paramter.

 protected String findStringIfAltSyntax(String expr) 
    This check is needed for backwards compatibility with 2.1.x
 protected Object findValue(String expr) 
    Finds a value from the OGNL stack based on the given expression. Will always evaluate expr against stack except when expr is null. If altsyntax (%{...}) is applied, simply strip it off.
 protected Object findValue(String expr,
    Class toType) 
    Evaluates the OGNL stack to find an Object of the given type. Will evaluate expr the portion wrapped with altSyntax (%{...}) against stack when altSyntax is on, else the whole expr is evaluated against the stack.

    This method only supports the altSyntax. So this should be set to true.

 protected Object findValue(String expr,
    String field,
    String errorMsg) 
    Evaluates the OGNL stack to find an Object value.

    Function just like findValue(String) except that if the given expression is null a error is logged and a RuntimeException is thrown constructed with a messaged based on the given field and errorMsg paramter.

 public Stack getComponentStack() 
    Gets the component stack of this component.
 public Map getParameters() 
    Gets the parameters.
 public ValueStack getStack() 
    Gets the OGNL value stack assoicated with this component.
 protected  void popComponentStack() 
    Pops the component stack.
 public  void setActionMapper(ActionMapper mapper) 
 public  void setThrowExceptionsOnELFailure(String throwException) 
 public boolean start(Writer writer) 
    Callback for the start tag of this component. Should the body be evaluated?
 protected String stripExpressionIfAltSyntax(String expr) 
    If altsyntax (%{...}) is applied, simply strip the "%{" and "}" off.
 public static String stripExpressionIfAltSyntax(ValueStack stack,
    String expr) 
    If altsyntax (%{...}) is applied, simply strip the "%{" and "}" off.
 protected String toString(Throwable t) 
    Constructs a string representation of the given exception.
 public boolean usesBody() 
    Overwrite to set if body shold be used.