This tag evaluates an expression and places the result in the javax.servlet.jsp.PageContext object, where the data is available to JSP scriptlets.
<netui-data:getData
resultId="string_resultId"
value="expression_value" />
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") %>
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>
[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui_databinding/getData/
<netui-data:getData> Tag Sample