| java.lang.Object org.apache.struts2.components.Component
All known Subclasses: org.apache.struts2.components.ElseIf, org.apache.struts2.components.ActionComponent, org.apache.struts2.components.AppendIterator, org.apache.struts2.components.Param, org.apache.struts2.components.Property, org.apache.struts2.components.Set, org.apache.struts2.components.Push, org.apache.struts2.components.Bean, org.apache.struts2.components.Text, org.apache.struts2.components.Date, org.apache.struts2.components.OptGroup, org.apache.struts2.components.I18n, org.apache.struts2.components.URL, org.apache.struts2.components.Else, org.apache.struts2.components.IteratorComponent, org.apache.struts2.components.MergeIterator, org.apache.struts2.components.UIBean, org.apache.struts2.components.If, org.apache.struts2.components.Include,
Component | public class Component (Code) | | Base class to extend for UI components.
This class is a good extension point when building reuseable UI components.
|
Constructor Summary | |
public | Component(ValueStack stack) Constructor. |
Method Summary | |
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. | public boolean | altSyntax() Is the altSyntax enabled? [TRUE]
See struts.properties where the altSyntax flag is defined. | 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. | protected String | determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult) Renders an action URL by consulting the
org.apache.struts2.dispatcher.mapper.ActionMapper . | 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) Renders an action URL by consulting the
org.apache.struts2.dispatcher.mapper.ActionMapper . | protected String | determineNamespace(String namespace, ValueStack stack, HttpServletRequest req) Determines the namespace of the current page being renderdd. | 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.
Parameters: writer - the output writer. Parameters: body - the rendered body. | protected boolean | end(Writer writer, String body, boolean popComponentStack) Callback for the start tag of this component. | 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 .
Parameters: field - field name used when throwing RuntimeException . Parameters: errorMsg - error message used when throwing RuntimeException . Parameters: e - the caused exception, can be null. | protected Component | findAncestor(Class clazz) Finds the nearest ancestor of this component stack.
Parameters: clazz - the class to look for, or if assignable from. | protected String | findString(String expr) Evaluates the OGNL stack to find a String value.
Parameters: expr - OGNL expression. | 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.
Parameters: expr - OGNL expression. Parameters: field - field name used when throwing RuntimeException . Parameters: errorMsg - error message used when throwing RuntimeException . | 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. | 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.
Parameters: expr - OGNL expression. Parameters: field - field name used when throwing RuntimeException . Parameters: errorMsg - error message used when throwing RuntimeException . | protected Object | findValue(String expr, Class toType) Evaluates the OGNL stack to find an Object of the given type. | public Stack | getComponentStack() Gets the component stack of this component. | public String | getId() Gets the id for referencing element. | public Map | getParameters() Gets the parameters.
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 | setId(String id) | public boolean | start(Writer writer) Callback for the start tag of this component.
Should the body be evaluated?
Parameters: writer - the output writer. | protected String | toString(Throwable t) Constructs a string representation of the given exception. | public boolean | usesBody() Overwrite to set if body shold be used. |
COMPONENT_STACK | final public static String COMPONENT_STACK(Code) | | |
stack | protected ValueStack stack(Code) | | |
Component | public Component(ValueStack stack)(Code) | | Constructor.
Parameters: stack - OGNL value stack. |
addAllParameters | public void addAllParameters(Map params)(Code) | | Adds all the given parameters to this component's own parameters.
Parameters: params - the parameters to add. |
addParameter | public void addParameter(String key, Object value)(Code) | | 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.
Parameters: key - the key of the new parameter to add. Parameters: value - the value assoicated with the key. |
altSyntax | public boolean altSyntax()(Code) | | Is the altSyntax enabled? [TRUE]
See struts.properties where the altSyntax flag is defined.
|
copyParams | public void copyParams(Map params)(Code) | | 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.
Parameters: params - the parameters to copy. |
determineActionURL | protected String determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult)(Code) | | Renders an action URL by consulting the
org.apache.struts2.dispatcher.mapper.ActionMapper .
Parameters: action - the action Parameters: namespace - the namespace Parameters: method - the method Parameters: req - HTTP request Parameters: res - HTTP response Parameters: parameters - parameters Parameters: scheme - http or https Parameters: includeContext - should the context path be included or not Parameters: encodeResult - should the url be encoded the action url. |
determineActionURL | 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)(Code) | | Renders an action URL by consulting the
org.apache.struts2.dispatcher.mapper.ActionMapper .
Parameters: action - the action Parameters: namespace - the namespace Parameters: method - the method Parameters: req - HTTP request Parameters: res - HTTP response Parameters: parameters - parameters Parameters: scheme - http or https Parameters: includeContext - should the context path be included or not Parameters: encodeResult - should the url be encoded Parameters: forceAddSchemeHostAndPort - should the scheme host and port be added to the url no matter what Parameters: escapeAmp - should the ampersands used separate parameters be escaped or not the action url. |
determineNamespace | protected String determineNamespace(String namespace, ValueStack stack, HttpServletRequest req)(Code) | | Determines the namespace of the current page being renderdd. Useful for Form, URL, and href generations.
Parameters: namespace - the namespace Parameters: stack - OGNL value stack Parameters: req - HTTP request the namepsace of the current page being rendered, is never null. |
end | public boolean end(Writer writer, String body)(Code) | | Callback for the end tag of this component.
Should the body be evaluated again?
NOTE: will pop component stack.
Parameters: writer - the output writer. Parameters: body - the rendered body. true if the body should be evaluated again |
end | protected boolean end(Writer writer, String body, boolean popComponentStack)(Code) | | 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.
Parameters: writer - the output writer. Parameters: body - the rendered body. Parameters: popComponentStack - should the component stack be popped? true if the body should be evaluated again |
fieldError | protected StrutsException fieldError(String field, String errorMsg, Exception e)(Code) | | Constructs a RuntimeException based on the given information.
A message is constructed and logged at ERROR level before being returned
as a RuntimeException .
Parameters: field - field name used when throwing RuntimeException . Parameters: errorMsg - error message used when throwing RuntimeException . Parameters: e - the caused exception, can be null. the constructed StrutsException . |
findAncestor | protected Component findAncestor(Class clazz)(Code) | | Finds the nearest ancestor of this component stack.
Parameters: clazz - the class to look for, or if assignable from. the component if found, null if not. |
findString | protected String findString(String expr)(Code) | | Evaluates the OGNL stack to find a String value.
Parameters: expr - OGNL expression. the String value found. |
findString | protected String findString(String expr, String field, String errorMsg)(Code) | | 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.
Parameters: expr - OGNL expression. Parameters: field - field name used when throwing RuntimeException . Parameters: errorMsg - error message used when throwing RuntimeException . the String value found. throws: StrutsException - is thrown in case of expression is null. |
findValue | protected Object findValue(String expr)(Code) | | 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.
Parameters: expr - the expression. Returns null if expr is null. the value, null if not found. |
findValue | protected Object findValue(String expr, String field, String errorMsg)(Code) | | 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.
Parameters: expr - OGNL expression. Parameters: field - field name used when throwing RuntimeException . Parameters: errorMsg - error message used when throwing RuntimeException . the Object found, is never null. throws: StrutsException - is thrown in case of not found in the OGNL stack, or expression is null. |
findValue | protected Object findValue(String expr, Class toType)(Code) | | 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.
Parameters: expr - OGNL expression. Parameters: toType - the type expected to find. the Object found, or null if not found. |
getComponentStack | public Stack getComponentStack()(Code) | | Gets the component stack of this component.
the component stack of this component, never null. |
getId | public String getId()(Code) | | Gets the id for referencing element.
the id for referencing element. |
getParameters | public Map getParameters()(Code) | | Gets the parameters.
the parameters. Is never null. |
getStack | public ValueStack getStack()(Code) | | Gets the OGNL value stack assoicated with this component.
the OGNL value stack assoicated with this component. |
popComponentStack | protected void popComponentStack()(Code) | | Pops the component stack.
|
start | public boolean start(Writer writer)(Code) | | Callback for the start tag of this component.
Should the body be evaluated?
Parameters: writer - the output writer. true if the body should be evaluated |
toString | protected String toString(Throwable t)(Code) | | Constructs a string representation of the given exception.
Parameters: t - the exception the exception as a string. |
usesBody | public boolean usesBody()(Code) | | Overwrite to set if body shold be used.
always false for this component. |
|
|