Data Model for Forms Data Model for Tables

Using Oracle Templates and JSP Tags 7-3

7.2 Overview of Forms and Tables

WebLogic Server provides a wl:form JSP tag that can render a variety of HTML input controls, such as text controls, check boxes, and radio controls. You can configure a form to be read-only or to allow user input. Forms that allow user input must include buttons that enable users to post the form data for processing in the business layer. WebLogic Server provides a wl:table JSP tag that renders data in a tabular format. Each row in the table represents a single entity such as a WebLogic Server instance, an application, or a log message see Figure 7–2 . You can configure table columns to render hypertext links, which enable users to navigate to pages that provide more information about an item in the table. You can also create a table column that contains an HTML check box control. If a user selects a check box for a table row and clicks a submit button, your extension can invoke business logic on behalf of the entire row. For example, you can use a check box to delete an item that a row represents. Both of these tags use Apache Struts Actions and ActionForms to pass data between the business layer and the presentation layer.

7.2.1 Data Models for Forms and Tables

Apache Struts supports multiple techniques for instantiating and populating ActionForm beans form beans. For example, you can code your own concrete Java bean that contains getter and setter methods for each property in the form. Or you can use the Struts DynaActionForm bean, which dynamically configures a Java bean to contain the properties that are declared in the Struts configuration file.

7.2.1.1 Data Model for Forms

If you are using Oracle JSP tags to render a form in the Administration Console, you can use any technique for creating and populating form beans that Struts supports. The example in Section 2.4, Example: How Struts Portlets Display Content uses a DynaActionForm bean instead of coding a custom Java bean. Regardless of the technique that you choose, your Java bean must contain the following property: ■ handle , which can be of type com.bea.console.handles.Handle or a custom Handle class that you create. The portal framework uses this property to correlate an ActionForm bean with the data source that populates the bean, such as an MBean. See Section 7.2.2, Handles for ActionForms and Row Beans.

7.2.1.2 Data Model for Tables

If you are using Oracle JSP tags to render a table in the Administration Console, you must create two form beans: one bean that represents the rows in the table called a row bean and another bean called a table bean that contains the collection of row beans. Each property in the row bean is rendered as a table column. For example, in Figure 7–2 , each row bean instance contains a name, state, health, and listenPort property. 7-4 Oracle Fusion Middleware Extending the Administration Console for Oracle WebLogic Server Figure 7–2 Row Beans and Table Bean To create a row bean, you must create a concrete Java bean that defines each property. You cannot use the Struts DynaActionForm bean to dynamically contain the properties that are declared in the Struts configuration file. To create a table bean, you can use any technique for creating and populating form beans that Struts supports. Regardless of the technique that you choose, your table bean must contain the following properties: ■ content , which must be of type java.util.Collection This is the property that you must use to contain the row beans. ■ handle , which can be of type com.bea.console.handles.Handle or a custom Handle class that you create. While the portal framework requires you to declare this property for form beans and table beans, its usefulness is limited with table beans. Typically, a table bean is simply a collection of row beans; the row beans expose an underlying data source but the table bean does not. Unless you need to keep track of which Action class has populated your table bean, you do not need to set the value of this property of the table bean but you must declare it. See Section 7.2.2, Handles for ActionForms and Row Beans.