netui-data:declarePageInput Tag

<netui-data:declarePageInput> Tag

This tag declares variables that are passed from the Controller file to the JSP page.

Syntax

<netui-data:declarePageInput
    name="string_name"
    type="string_type" />

Description

This tag 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

Attributes

nameThe name of the variable to reference.
 
RequiredSupports runtime expression evaluationData bindable
YesNoNo

typeThe expected data type of the variable.
 
RequiredSupports runtime expression evaluationData bindable
YesNoNo

Sample

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}" />

Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/WebApp/tagSamples/netui_databinding/declarePageInput/

Related Topics

<netui-data:declarePageInput> Tag Sample