<netui-data:declarePageInput> Tag
Declares variables that are passed from
the Controller file to the JSP page.
<netui-data:declarePageInput
name="name"
[required="required"]
type="type" />
Declares variables that are passed from
the Controller file to the JSP page.
The variable's lifetime is the same as that of the JSP page on which it
is declared.
On the Controller file, use the addPageInput
method
(a method on the
Forward
class)
to make the variable available to the <netui-data:declarePageInput> tag.
Forward f = new Forward("success");
f.addPageInput("myData", new MyData());
Then, on the JSP page, declare the variable with the <netui-data:declarePageInput> tag.
<netui-data:declarePageInput name="myData" type="myPageFlow.MyPageFlowController.MyData"/>
Once declared, the variable can be referenced using the
{pageInput...}
data binding context.
The name
attribute is used as the identifier for the variable inside
of this binding context, and the type
attribute is used to identify
the expected type of this variable.
<netui:label value="{pageInput.myData}"/>
Using the <netui-data:declarePageInput> has the following advantages
- The presence of <netui-data:declarePageInput> tags in a JSP file
helps to indicate clearly the type of data expected at run time. This
information about the incoming data helps your team understand any
data dependencies a given JSP page may have on the Controller file.
Attributes |
name |
Required: Yes | Supports
runtime evaluation: No | Data bindable: No |
|
The name of the variable to reference. |
required |
Required: No | Supports
runtime evaluation: No | Data bindable: |
|
|
type |
Required: Yes | Supports
runtime evaluation: No | Data bindable: No |
|
The expected data type of the variable. |
This sample shows how a variable, foo
, is defined in the Controller file,
and its value is
passed to a JSP page by using the addPageInput
method and the
<netui-data:declarePageInput> tag.
Code in the Controller file...
/**
* @jpf:action
* @jpf:forward name="simple" path="simple.jsp"
*/
public Forward simple()
{
Forward f = new Forward("simple");
f.addPageInput("fooBean", new FooBean());
return f;
}
public static class FooBean
{
private String foo = "A Foo String";
public String getFoo()
{
return foo;
}
public void setFoo(String foo)
{
this.foo = foo;
}
}
Code in a JSP page...
<netui-data:declarePageInput name="fooBean" type="pageInput.PageInputController.FooBean"/>
...
fooBean.foo: <netui:label value="{pageInput.fooBean.foo}" />