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

> - 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.
> - At design time each <netui-data:declarePageInput> tag, once added to a JSP page, enables an additional WebLogic Workshop IDE feature to discover properties about your JSP source code.

>   For example, the presence of a <netui-data:declarePageInput> tag on a JSP page causes the Workshop IDE to display the declared variable in the Data Palette's "Page Inputs" section. Once the variable is displayed in the Data Palette, you can (1) drag and drop the variable from the Data Palette, and (2) set properties on the variable. Note that the Data Palette will not display the following data types:

>   primitive Java types
>   java.*
>   javax.*
>   com.sun.*
>   org.apache.struts.*
>   com.bea.*

## Attributes

name | The name of the variable to reference.
Required | Supports runtime expression evaluation | Data bindable
Yes | No | No
type | The expected data type of the variable.
Required | Supports runtime expression evaluation | Data bindable
Yes | No | No

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