WebLogic Workshop includes NetUI, which allows you to rapidly assemble applications that display data returned from Liquid Data queries.
When you create a Liquid Data control, an XMLBean is generated for the target schema of each stored query included as a method in the control. The following sections represent the basic steps for using NetUI to display results from a Liquid Data Control:
You can generate a page flow from a Liquid Data Control (.jcx) file. When you generate the page flow, Workshop creates the page flow, a start page (index.jsp), and a JSP file for each method you specify in the Page Flow wizard.
Perform the following steps to generate a page flow from a Liquid Data control.
Figure 1-13 Enter a Name for the Page Flow
Figure 1-14 Choose Liquid Data Methods for the Page Flow
Workshop generates the .jpf Java Page Flow file, a start page (index.jsp), and a JSP file for each method you specify in the Page Flow wizard.
You can add a Liquid Data Control to an existing Page Flow .jpf file. The procedure is the same as adding a Liquid Data Control to a Web Service, described in To Add a Liquid Data Control to an Existing Web Service File, except instead of opening the Web Service in Design View, you open the Page Flow .jpf file in Action View.
You can also add a control to an existing page flow from the Page Flow Data Palette (available in Flow View and Action View of a Page Flow), as shown in Figure 1-15.
Figure 1-15 Adding a Control to a Page Flow from the Data Palette
***THIS SHOULD CHANGE FOR SP2***
In order to use the NetUI features to drag and drop data from an XMLBean into a JSP, you must first create variables in the page flow .jpf file. NetUI can traverse the XMLBean data structure until it encounters an array. When you create the Liquid Data control and the XMLBeans are generated, the XMLBean generation defines an array for each element in the schema that is repeatable. When there is an array (corresponding to a repeatable element), you need to define a new variable to access the data in the array. You therefore need one variable from each repeatable parent node of the XML data represented in the XMLBean. Define each variable with a type corresponding to the XMLBean object of the parent node.
Define the variables in the class that extend the PageFlowController class. For example, consider the case where you are trying to display XML data of the following form:
<CUSTOMER>data</CUSTOMER> ......<PROMOTION>promotion data</PROMOTION> ......
You can add the following code snippet, which shows two variables (shown in bold type) added to the page flow:
public class myPageFlowController extends PageFlowController { /** * This is the control used to generate this pageflow * @common:control */ private aLDControl myControl; // add Variables with XMLBeam types from the generated XMLBeans public transient com.mycorp.crm.CUSTDocument aVar; public transient com.mycorp.crm.CUSTDocument.PROFILE.CUST.PROMOTION[] bVar;
This code snippet declares two variables in the page flow, aVar and bVar, and these variables will display in the IDE to allow for drag-and-drop operations onto JSP files.
Figure 1-16 Page Flow Variables for XMLBean Objects
When you drag-and-drop an array onto a JSP file, the NetUI Repeater Wizard appears and guides you through selecting the data you want to display.
Perform the following steps to add variables of XMLBean types for your query.
mySchema.CUSTOMERPROFILEDocument myQuery(java.lang.String custid);
public transient mySchema.CUSTOMERPROFILEDocument myCustomerVar;
public transient CASES customerCases;
Figure 1-17 Workshop Prompting for Type Clarification
You must initialize your XMLBean variables in the Page Flow. Initializing the variables ensures that the data bindings to the variables work correctly and that there are no tag exceptions when the JSP displays the results the first time.
Perform the following steps to initialize the XMLBean variables in the Page Flow:
The following sample code shows an example of initializing a variable on the Page Flow. The code (and comments) in bold is what was added. The rest of the code was generated when the Page Flow was generated from the Liquid Data control (see Generating a Page Flow From a Control).
/** * Action encapsulating the control method :RTLCustomerProfile * @jpf:action * @jpf:forward name="success" path="index.jsp" * @jpf:catch method="exceptionHandler" type="Exception" */ public Forward RTLCustomerProfile( RTLCustomerProfileForm aForm ) throws Exception { schemasBeaComLdCustview.PROFILEVIEWDocument var = myControl.RTLCustomerProfile( aForm.custid ); getRequest().setAttribute( "results", var ); //initialize the profile variable to var from the above statement profile=var; // test to see if there is no data returned to handle cases where // the query returns successfully but has no results (when custid // does not exist, for example) if (var !=null && var.getPROFILEVIEW().getCUSTOMERPROFILEArray().length > 0) customerProfile=var.getPROFILEVIEW().getCUSTOMERPROFILEArray(0); return new Forward( "success" ); }
Once you create and initialize your variables in the Page Flow, you can drag and drop the variables onto a JSP file. When you drag and drop an XMLBean variable onto a JSP File, Workshop displays a wizard to guide you through the process of selecting the data you want to display.
Perform the following to add a NetUI repeater tag (used to display the data from a Liquid Data query) to a JSP file.
Note: You can only drag and drop leaf nodes from the Page Flow Properties.
Note: The repeater wizard displays everything contained in the XMLBean, which includes more than the data fields from your schema. Be sure to uncheck the fields you do not need (for example, nilSTATUSDATE).
Figure 1-19 Repeater Wizard Select Format Screen
Workshop generates the layout for your data.
You can create repeater tags inside of other repeater tags. You can display nested repeaters on the same page (in nested tables, for example) or you can set up Page Flow actions to display the nested level on another page (with a link, for example).
Perform the following steps to create a nested repeater tag.
Perform the following steps to add code in your JSP file to handle null values for your data. It is a common JSP design pattern to add conditional code to handle null values. If you do not handle null values, your page will display errors for parameterized queries until values are entered for the parameters.
<% PageFlowController pageFlow = PageFlowUtils.getCurrentPageFlow(request); if ( ((pF2Controller)pageFlow).profile == null || ((pF2Controller)pageFlow).profile.getPROFILEVIEW().getCUSTOMERPROFILEArray() == null || ((pF2Controller)pageFlow).profile.getPROFILEVIEW().getCUSTOMERPROFILEArray().length == 0){ %> <p>No data</p> <% } else {%> <netui-data:repeater dataSource= "{pageFlow.profile.PROFILEVIEW.CUSTOMERPROFILEArray}"> <netui-data:repeaterHeader> <table cellpadding="2" border="1" class="tablebody" > <tr> <!- the rest of the table and NetUI code goes here --> <td><netui:label value ="{container.item.PROFILE.DEFAULTSHIPMETHOD}"></netui:label></td> </tr> </netui-data:repeaterItem> <netui-data:repeaterFooter></table></netui-data:repeaterFooter> </netui-data:repeater> <% }%>