|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.struts2.components.Component
public class Component
Base class to extend for UI components.
This class is a good extension point when building reuseable UI components.
Field Summary | |
---|---|
static java.lang.String |
COMPONENT_STACK
|
protected java.lang.String |
id
|
protected java.util.Map |
parameters
|
protected com.opensymphony.xwork2.util.OgnlValueStack |
stack
|
Constructor Summary | |
---|---|
Component(com.opensymphony.xwork2.util.OgnlValueStack stack)
Constructor. |
Method Summary | |
---|---|
void |
addAllParameters(java.util.Map params)
Add's all the given parameters to this componenets own parameters. |
void |
addParameter(java.lang.String key,
java.lang.Object value)
Add's the given key and value to this components own parameter. |
boolean |
altSyntax()
Is the altSyntax enabled? [TRUE] See struts.properties where the altSyntax flag is defined. |
void |
copyParams(java.util.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 java.lang.String |
determineActionURL(java.lang.String action,
java.lang.String namespace,
java.lang.String method,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.util.Map parameters,
java.lang.String scheme,
boolean includeContext,
boolean encodeResult)
Renders an action URL by consulting the ActionMapper . |
protected java.lang.String |
determineNamespace(java.lang.String namespace,
com.opensymphony.xwork2.util.OgnlValueStack stack,
javax.servlet.http.HttpServletRequest req)
Determines the namespace of the current page being renderdd. |
boolean |
end(java.io.Writer writer,
java.lang.String body)
Callback for the end tag of this component. |
protected boolean |
end(java.io.Writer writer,
java.lang.String body,
boolean popComponentStack)
Callback for the start tag of this component. |
protected StrutsException |
fieldError(java.lang.String field,
java.lang.String errorMsg,
java.lang.Exception e)
Constructs?a RuntimeException based on the given information. |
protected Component |
findAncestor(java.lang.Class clazz)
Finds the nearest ancestor of this component stack. |
protected java.lang.String |
findString(java.lang.String expr)
Evaluates the OGNL stack to find a String value. |
protected java.lang.String |
findString(java.lang.String expr,
java.lang.String field,
java.lang.String errorMsg)
Evaluates the OGNL stack to find a String value. |
protected java.lang.Object |
findValue(java.lang.String expr)
Finds a value from the OGNL stack based on the given expression. |
protected java.lang.Object |
findValue(java.lang.String expr,
java.lang.Class toType)
Evaluates the OGNL stack to find an Object of the given type. |
protected java.lang.Object |
findValue(java.lang.String expr,
java.lang.String field,
java.lang.String errorMsg)
Evaluates the OGNL stack to find an Object value. |
java.util.Stack |
getComponentStack()
Get's the component stack of this component. |
java.lang.String |
getId()
Get's the id for referencing element. |
java.util.Map |
getParameters()
Get's the parameters. |
com.opensymphony.xwork2.util.OgnlValueStack |
getStack()
Get's the OGNL value stack assoicated with this component. |
protected void |
popComponentStack()
Pops the component stack. |
void |
setId(java.lang.String id)
id for referencing element. |
boolean |
start(java.io.Writer writer)
Callback for the start tag of this component. |
protected java.lang.String |
toString(java.lang.Throwable t)
Constructs a string representation of the given exception. |
boolean |
usesBody()
Overwrite to set if body shold be used. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COMPONENT_STACK
protected com.opensymphony.xwork2.util.OgnlValueStack stack
protected java.util.Map parameters
protected java.lang.String id
Constructor Detail |
---|
public Component(com.opensymphony.xwork2.util.OgnlValueStack stack)
stack
- OGNL value stack.Method Detail |
---|
public com.opensymphony.xwork2.util.OgnlValueStack getStack()
public java.util.Stack getComponentStack()
public boolean start(java.io.Writer writer)
writer
- the output writer.
public boolean end(java.io.Writer writer, java.lang.String body)
writer
- the output writer.body
- the rendered body.
protected boolean end(java.io.Writer writer, java.lang.String body, boolean popComponentStack)
writer
- the output writer.body
- the rendered body.popComponentStack
- should the component stack be popped?
protected void popComponentStack()
protected Component findAncestor(java.lang.Class clazz)
clazz
- the class to look for, or if assignable from.
protected java.lang.String findString(java.lang.String expr)
expr
- OGNL expression.
protected java.lang.String findString(java.lang.String expr, java.lang.String field, java.lang.String errorMsg)
RuntimeException
is thrown
constructed with a messaged based on the given field and errorMsg paramter.
expr
- OGNL expression.field
- field name used when throwing RuntimeException
.errorMsg
- error message used when throwing RuntimeException
.
StrutsException
- is thrown in case of expression is null.protected StrutsException fieldError(java.lang.String field, java.lang.String errorMsg, java.lang.Exception e)
RuntimeException
based on the given information.
A message is constructed and logged at ERROR level before being returned
as a RuntimeException
.
field
- field name used when throwing RuntimeException
.errorMsg
- error message used when throwing RuntimeException
.e
- the caused exception, can be null.
StrutsException
.protected java.lang.Object findValue(java.lang.String expr)
expr
against stack except when expr
is null. If altsyntax (%{...}) is applied, simply strip it off.
expr
- the expression. Returns null if expr is null.
public boolean altSyntax()
struts.properties
where the altSyntax flag is defined.
protected java.lang.Object findValue(java.lang.String expr, java.lang.String field, java.lang.String errorMsg)
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.
expr
- OGNL expression.field
- field name used when throwing RuntimeException
.errorMsg
- error message used when throwing RuntimeException
.
StrutsException
- is thrown in case of not found in the OGNL stack, or expression is null.protected java.lang.Object findValue(java.lang.String expr, java.lang.Class toType)
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.
expr
- OGNL expression.toType
- the type expected to find.
protected java.lang.String determineActionURL(java.lang.String action, java.lang.String namespace, java.lang.String method, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.util.Map parameters, java.lang.String scheme, boolean includeContext, boolean encodeResult)
ActionMapper
.
action
- the actionnamespace
- the namespacemethod
- the methodreq
- HTTP requestres
- HTTP responseparameters
- parametersscheme
- http or httpsincludeContext
- should the context path be included or notencodeResult
- should the url be encoded
protected java.lang.String determineNamespace(java.lang.String namespace, com.opensymphony.xwork2.util.OgnlValueStack stack, javax.servlet.http.HttpServletRequest req)
namespace
- the namespacestack
- OGNL value stackreq
- HTTP request
public void copyParams(java.util.Map params)
params
- the parameters to copy.protected java.lang.String toString(java.lang.Throwable t)
t
- the exception
public java.util.Map getParameters()
public void addAllParameters(java.util.Map params)
params
- the parameters to add.public void addParameter(java.lang.String key, java.lang.Object value)
key
- the key of the new parameter to add.value
- the value assoicated with the key.public java.lang.String getId()
public void setId(java.lang.String id)
public boolean usesBody()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |