<netui-data:getData> Tag

Evaluates an expression and places the result in the javax.servlet.jsp.PageContext object, where the data is available to JSP scriptlets.

Syntax

<netui-data:getData
    resultId="resultId"
    value="value" />

Description

Evaluates an expression and places the result in the javax.servlet.jsp.PageContext object, where the data is available to JSP scriptlets. This tag can be used to extract data from forms, Controller files, and any data binding context and make it available to scriptlets.

The following <netui-data:getData> tag extracts data from the Controller file and places it in the myData field of the PageContext object:

    <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:

    <%= pageContext.getAttribute("myData") %>

Attributes
resultId
Required: Yes  |   Supports runtime evaluation: No  |   Data bindable: No

Specifies the property of the PageContext object where the data will be stored.
value
Required: Yes  |   Supports runtime evaluation: Yes  |   Data bindable: Yes

The data binding expression to evaluate. The result will be stored in the PageContext object as specified in the resultId attribute.

 
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>