|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectTagSupport
BodyTagSupport
AbstractClassicTag
GetData
public class GetData
This tag evaluates an expression and places the result in the
PageContext object, where the data is available to the JSP EL and JSP scriptlet.
This tag can be used to extract data from forms, Controller files, and any data binding context and
make it available to scriptlets.
In the following example, the getData tag gets the value of a property in the page flow and
makes it available to the JSP via the JSP EL implicit object ${pageScope}.
<netui-data:getData resultId="myData" value="${pageFlow.myData}"/>
The following scriptlet extracts the data from the PageContext object and writes it to
the rendered HTML:
${pageScope.myData}
In this first example, the <netui-data:getData> tag loads data into the PageContext's
attribute map. It can then be accessed using the JspContext.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 example 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:span 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>
PageContext's
attribute map. It can then be accessed using the JspContext.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 example 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:span 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>
| Field Summary |
|---|
| Fields inherited from class AbstractClassicTag |
|---|
DefaultNamingChain, EMPTY_STRING, NETUI_UNIQUE_CNT |
| 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 |
| Constructor Summary | |
|---|---|
GetData()
|
|
| Method Summary | |
|---|---|
int |
doEndTag()
Evaluate the expression at the value attribute and store the result in the
PageContext under the attribute key specified in setResultId(String). |
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 attribute name under which the result of evaluating an expression will be stored in the PageContext.. |
void |
setValue(Object value)
The data binding expression to evaluate. |
| 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 |
| Constructor Detail |
|---|
public GetData()
| Method Detail |
|---|
public String getTagName()
getTagName in interface INetuiTaggetTagName in class AbstractClassicTagpublic void setValue(Object value)
PageContext
object as specified in the resultId attribute.
value - the expression to evaluatepublic void setResultId(String resultId)
PageContext..
resultId - the String keypublic int doStartTag()
doStartTag in interface TagdoStartTag in class BodyTagSupportTag.SKIP_BODY
public int doEndTag()
throws JspException
value attribute and store the result in the
PageContext under the attribute key specified in setResultId(String).
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.
doEndTag in interface TagdoEndTag in class BodyTagSupportTag.EVAL_PAGE
JspExceptionprotected void localRelease()
localRelease in class AbstractClassicTag
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||