org.apache.beehive.netui.tags.databinding.script
Class GetData
Object
TagSupport
BodyTagSupport
AbstractClassicTag
GetData
- All Implemented Interfaces:
- Serializable, BodyTag, IterationTag, JspTag, Tag, INetuiTag
public class GetData
- extends AbstractClassicTag
This tag evaluates an expression and places the result of expression evaluation
in a JSP's PageContext
. This can be used to extract objects from forms,
page flows, and other objects that can be databound; once in the JSP,
scriptlet can be written using these objects by accessing them through the
JspContext.getAttribute(java.lang.String)
method.
- See Also:
- Serialized Form
- Example
- In this first sample, the <netui-data:getData> tag loads data into the
PageContext
object. You can subsequently access the data
through the PageContext's getAttribute(String)
method.
<netui:form action="lastNameAction" focus="lastname">
...
<netui-data:getData resultId="first" value="{actionForm.firstname}"/>
...
<%
String firstName = (String) pageContext.getAttribute("first");
System.out.println("First Name = " + firstName);
...
%>
...
</netui:form>
This next sample shows how to use <netui-data:getData> and the PageContext
inside of other containers, in this case a <netui-data:repeater> tag. The <netui-data:getData> below
extracts each element as the <netui-data:repeater> iterates over the data set and writes it to the Java console:
<netui-data:repeater dataSource="{pageFlow.strArr}">
...
<netui-data:repeaterItem>
<netui:label value="{container.item}" />
<netui-data:getData resultId="item" value="{container.item}"/>
<%
String currentItem = (String) pageContext.getAttribute("item");
System.out.println(currentItem);
...
%>
</netui-data:repeaterItem>
...
</netui-data:repeater>
Fields inherited from class BodyTagSupport |
bodyContent |
Fields inherited from class TagSupport |
id, pageContext |
Fields inherited from interface BodyTag |
EVAL_BODY_BUFFERED, EVAL_BODY_TAG |
Fields inherited from interface IterationTag |
EVAL_BODY_AGAIN |
Fields inherited from interface Tag |
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
Method Summary |
int |
doEndTag()
Evaluate the expression at the value attribute and
store the result in the PageContext under the attribute key
resultId . |
int |
doStartTag()
Start the tag evaluation. |
String |
getTagName()
Get the name of this tag. |
protected void |
localRelease()
Reset all of the fields of this tag. |
void |
setResultId(String resultId)
Set the String key under which the result of evaluating an expression
will be stored in the PageContext. |
void |
setValue(Object value)
Set the expression to evaluate. |
Methods inherited from class AbstractClassicTag |
addTagIdMapping, applyNamingChain, getErrorsReport, getNamingChain, getNextId, getScriptReporter, getUserLocale, hasErrors, qualifyAttribute, registerTagError, registerTagError, renderAttribute, reportAndExit, reportErrors, rewriteName, setNonEmptyValueAttribute, setRequiredValueAttribute, write |
Methods inherited from class BodyTagSupport |
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent |
Methods inherited from class TagSupport |
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setParent, setValue |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface Tag |
getParent, setPageContext, setParent |
GetData
public GetData()
getTagName
public String getTagName()
- Get the name of this tag. This is used to identify the type of this tag
for reporting tag errors.
- Specified by:
getTagName
in interface INetuiTag
- Specified by:
getTagName
in class AbstractClassicTag
- Returns:
- a constant String representing the name of this tag.
setValue
public void setValue(Object value)
- Set the expression to evaluate.
- Parameters:
value
- the expression to evaluate
setResultId
public void setResultId(String resultId)
- Set the String key under which the result of evaluating an expression
will be stored in the PageContext.
- Parameters:
resultId
- the String key
doStartTag
public int doStartTag()
- Start the tag evaluation. This tag ignores its body content.
- Specified by:
doStartTag
in interface Tag
- Overrides:
doStartTag
in class BodyTagSupport
- Returns:
- SKIP_BODY
doEndTag
public int doEndTag()
throws JspException
- Evaluate the expression at the
value
attribute and
store the result in the PageContext under the attribute key
resultId
. If an existing key in the PageContext's
attribute map exists, a warning will be written to the log file.
If errors occur during expression evaluation, they will be reported
in the JSP page. If the value returned by the expression is null,
an attribute named resultId
will be removed from
the PageContext's attribute map.
- Specified by:
doEndTag
in interface Tag
- Overrides:
doEndTag
in class BodyTagSupport
- Returns:
- EVAL_PAGE
- Throws:
JspException
localRelease
protected void localRelease()
- Reset all of the fields of this tag.
- Overrides:
localRelease
in class AbstractClassicTag