Declaring Page Inputs

The <netui-data:declarePageInput> tag allows you to declare variables that will be passed from the page flow controller to the JSP page. You can assign an initial value to each variable that will be used (for display purposes only) on the JSP.

In the source JSP file, the <netui-data:declarePageInput> tag helps to indicate clearly the type of data that is expected at run time. This information about the incoming data helps your team understand any data dependencies this JSP page may have.

At design time each <netui-data:declarePageInput> tag, once added to a JSP page, enables an additional WebLogic Workshop IDE feature in which the properties on the source object can be discovered. For example, after a database control is referenced in a page flow action, and the <netui-data:declarePageInput> tag is placed on the JSP page, you can use the Data Palette pane's "Page Inputs" section to select one or more properties, such as ITEMNAME and PRICE. When you drag a property from the Page Inputs section to your JSP page, a read-only <netui:label> tag will be added with the appropriate data binding expression already completed for you. For example:

<netui:label value="{pageInput.item.itemname}">

Declare Page Input Sample

The WebLogic Workshop sample application contains a page flow that demonstrates this page input feature. Start in the following directory:

<WEBLOGIC_HOME>/samples/workshop/SamplesApp/WebApp/pageInput

The sample page flow contains two JSP files, simple.jsp and next.jsp, that declare page inputs. The simple.jsp page contains these tags:

<netui-data:declarePageInput name="fooBean" type="pageInput.PageInputController.FooBean"/>
<netui-data:declarePageInput name="barBean" type="pageInput.PageInputController.BarBean"/>
<netui-data:declarePageInput name="simpleForm" type="pageInput.PageInputController.SimpleForm"/>

In the page flow controller class, an action method named simple is defined as follows:

 /**
  * @jpf:action
  * @jpf:forward name="simple" path="simple.jsp"
  */
   public Forward simple()
   {
       Forward f = new Forward("simple");
       f.addPageInput("fooBean", new FooBean());
       f.addPageInput("barBean", new BarBean());
       f.addPageInput("simpleForm", new SimpleForm());
       return f;
   }

At design time in simple.jsp, because the <netui-data:declarePageInput> tags were present on the page, the Data Palette pane contained a Page Input category. In the following sample screen, we have already expanded each JavaBean's entry to see the variables they contain:

Note that the Data Palette will not display the following data types:

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

By selecting the foo property and dragging it to the JSP Source View (taking care to note the insertion point), the IDE will generate the following tag attributes for us:

<netui:label value="{pageInput.fooBean.foo}"></netui:label>

You can then modify the tag, as we did in the sample application.

The page flow controller class, PageInputController.jpf, contains three JavaBean classes that provide the data for the page inputs in simple.jsp. For details, see the page flow source file.

For the next.jsp page inputs, this page flow uses a database control that retrieves several fields from an ITEMS table and loads them into an array. Here is a portion of the database control JCX file:

 * @jc:connection data-source-jndi-name="cgDataSource" 
 */ 
 public interface ItemsDBControl2 extends DatabaseControl, com.bea.control.ControlExtension
 { 
     static public class Item
     {
         public int itemnumber;
         public String itemname;
         public int quantityavailable;
         public double price;
     }
   
     static final long serialVersionUID = 1L;
     /**
      * @jc:sql statement="SELECT ITEMNUMBER, ITEMNAME, QUANTITYAVAILABLE, PRICE FROM ITEMS"
      */
      Item[] getAllItems() throws SQLException;
 }

In the page flow controller class, one of the import statements is:

import pageInput.ItemsDBControl2.Item;

And the page flow calls the control:

 /**
  * @common:control
  */
  private pageInput.ItemsDBControl2 itemsDB;

The page flow also defines an action method that gets all items in the array.

 /**
  * @jpf:action
  * @jpf:forward name="success" path="next.jsp"
  */
  public Forward next()
      throws SQLException
  {
      Item[] items = itemsDB.getAllItems();
      return new Forward("success", "items", items);
  } 

Notice the new Forward object's parameters:

In the next.jsp page that is part of this page flow sample, we can use a <netui-data:declarePageInput> tag and a <netui-data:repeater> to display the retrieved values. For example:

 <netui-data:declarePageInput name="items" type="ItemsDBControl2.Item[]"/>
   <p>&nbsp;</p>
   <p><b>An array of product items:</b>
   <netui-data:repeater dataSource="{pageInput.items}">
       <netui-data:repeaterHeader>
           <ul> 
       </netui-data:repeaterHeader>
       <netui-data:repeaterItem>
           <li>
           <netui:label value="{container.item.itemname}" />
           </li>
       </netui-data:repeaterItem>
       <netui-data:repeaterFooter> </ul> </netui-data:repeaterFooter>
   </netui-data:repeater>

See the sample's pre-rendered source files in:

 <WEBLOGIC_HOME>/samples/workshop/SamplesApp/WebApp/pageInput

Then run the sample to view the results.

Related Topics

<netui-data:declarePageInput> Tag Sample

Presenting Complex Data Sets in JSPs

Using Data Binding in Page Flows