Placing a Thin Bean in a Form

The BI Beans thin beans use form fields to transfer information in the events that they render and handle, so you must add each thin bean to a form before adding it to the HTML page. You can place more than one thin bean in a single form.

When you use JSP tags, the Render tag must be in the <FORM> tag. If you use the JSP wizard, the Render tag is placed in the <FORM> tag for you. When you use UIX tags, the UINode elements must appear in the form element.

As the thin-bean UINode renders HTML, it gets the name of the parent FormBean from the RenderingContext. When a user clicks in the thin bean, this triggers an event in the browser, and then the thin-bean UINode submits the parent form.

Using the UIX FormBean

In a servlet application, the simplest way to place a thin bean in a form is to use a UIX FormBean. You add each thin-bean UINode as a child of the FormBean. The FormBean class is defined in the oracle.cabo.ui.beans.form package. The following code shows how to add a thin crosstab to a FormBean.


ThinCrosstab crosstab = new ThinCrosstab(); CrosstabBean crosstabUINode = new CrosstabBean(crosstab); FormBean form = new FormBean("MyForm"); form.addIndexedChild(crosstabUINode); // Now add the form to the HTML body and render

After you add the crosstab UINode to the FormBean, you can add the FormBean to the rest of the HTML page.

Using a form outside of the UIX Components tree

If you do not use UIX Components to construct the HTML page, then you still need a form in which to place the thin-bean UINode. For example, when you use JSPs to include thin beans in your application, you need to put the thin bean in a form. You must use the PseudoFormBean, which is defined in the oracle.dss.thin.beans.util package, to represent this form in UIX Components.

When you use JSPs, you give the PseudoFormBean the name of the parent FORM element, as shown in the following example.


<html> <body> <form action="myServlet" nem = "myForm"> <% CrosstabBean crosstab = new CrosstabBean(new ThinCrosstab()); PseudoFormBean form = new PseudoFormBean("myForm"); // set EndForm to true, as this is the last thing to add to the form form.setEndForm(new Boolean(true)); // add the crosstab to the form form.addIndexedChild(crosstab); // render the form form.render(newServletRenderingContext(pageContext)); %> </form> </body> </html>

Note: You can use the BI Beans JSP tags to produce JSP code for you.