Initializing an Application

How to:

Reference:

This topic describes the steps for initializing a WebFOCUS Enable application and provides sample initialization code. It also describes the functions for performing initialization, running a WebFOCUS procedure, and getting data into the application.


Top of page

x
Procedure: How to Initialize an Application
  1. Include the code creationComplete="initApp()" in the <mx:Application> tag.

    This code tells the application that the initApp() function will run first.

  2. Declare basedataarray as an ibiObject. This is in ibiFLEXEnable.
  3. Define FEX as an ad hoc fex call using HTTP.
    1. The methods in ibiFLEXEnable require that you send it an HTTP call.
    2. You also need to decide what to do with the results. For example, create a function called dataReady().
    3. The function dataReady() calls a component to load data according to the function call to the ibiObject.


Example: Sample Code for Initializing an Application, Running a Procedure, and Getting Data
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
    creationComplete="initApp()" width="862">
  <mx:Script>
    <![CDATA[
      //Instantiate an ibiObject
      public var basedataarray:ibiObject = new ibiObject();
      // assigning URL
      public var fex:String = "http://localhost:8080/ibi_apps/WFServlet
         ?IBIF_ex=xmltest";
      //Initializing an Application
      public function initApp():void
     {
       basedataarray.init(fex,dataReady);
     }
     public function dataReady(grid:ibiObject,obj:*):void
     //public function dataReady(grid:ibiObject):void
     {
       //populateGrid will put the data into ArrayCollection prGridfiltered
       basedataarray.populateGrid(false); //fill out the base array collection
       load_main1(); //load the named grid with the data from the basearray
     }
     public function load_main1():void
     {
        //Assign the populated Data to the dataGrid as a dataProvider
        main1.dataProvider = basedataarray.prGridfiltered;
     }
    ]]>
  </mx:Script>
  <!-- Declare the grid in the MXML -->
  <mx:DataGrid x="10" y="22" width="268" height="156" id="main1">
    <mx:columns>
      <mx:DataGridColumn headerText="REGION" dataField="REGION"/>
      <mx:DataGridColumn headerText="ST" dataField="ST"/>
      <mx:DataGridColumn headerText="DOLLARS" dataField="DOLLARS"/>
      <mx:DataGridColumn headerText="UNITS" dataField="UNITS"/>
    </mx:columns>
  </mx:DataGrid>
</mx:Application>


Top of page

x
Reference: Functions for Initializing, Running a Procedure, and Getting Data
public function init(url:String,callback:Function): void

Description:
Creates an HttpService object and executes the send method.

Parameters:
url of type String: Takes a URL to the procedure (FEX) in c://localhost:8080/ibi_apps.

callback of type Function: Points to the function you are passing in the init method.

Note: Flash Player 6 and later interprets external text files as Unicode. To enable the Flash Player to interpret external files in the default code page of the operating system running the player, the useCodePage property must be set to true (by default, it is set to false). For users not using API, the useCodePage is set to true automatically when ibiCanvas is added. To manually set this, you must apply the following code to initApp() or whatever function you are using for initialization in your ActionScript:

System.useCodePage=true;

When this code is present, the Flash Player interprets external text using the traditional code page of the operating system running the Flash Player. This is generally CP1252 for an English Windows operating system and Shift-JIS for a Japanese operating system. If you set useCodePage to true, the traditional code page of the operating system running the player must include the characters used in your external text file in order to display your text. For example, if you load an external text file that contains Chinese characters, those characters cannot display on a system that uses the CP1252 code page because that code page does not include Chinese characters. When possible, you should ensure that users on all platforms can view external text files used in your SWF files that are Adobe Flash Player compatible by encoding all external text files as Unicode and leaving useCodePage set to false. This way, the Flash Player interprets the text as Unicode.

public function populateGrid(setGrid:Boolean):void

Description:
Builds an ArrayCollection from the .XML file that is generated by WebFOCUS. It returns nothing; it is void.

Parameters:
setGrid of type Boolean: Takes false if you want to create an ArrayCollection; otherwise, takes true.

public function setData():void
Description:
Sets all the data returned from an .XML file to the GridValues, GridLabels, GridType, GridTitle, GridAlias, GridFormat, GridDesc (Array type).
public function aggregate(groupLabel:Array,byLabel:Array, calculateOption:Array,useFilter:Boolean,createGrid:Boolean):ArrayCollection

Description:
Groups the rows of a DataGrid according to specified criteria. The function returns an ArrayCollection that contains the grouped rows. When the items are displayed in groups, a new column is added. This new column shows how many items of each kind were found (how many items in each group). The new column can also show the maximum, distinct, count, minimum, sum, or average value of the items of each kind instead. This option is specified in the calculateOption parameter.

Remarks:
Must populate the grid first. Example: Grid.populateGrid(true)

Parameters:
groupLabel of type Array: Specifies which column is used as the criteria for calculating the sum, maximum, minimum, count, distinct, or average value of the grouped items in the grid.

byLabel of type Array: Specifies which column is used as the criteria for grouping the rows of a DataGrid. The rows of the grid are grouped according to the byLabel value.

calculateOption of type Array: After grouping the rows, the aggregate function creates a new column that will display the sum, maximum, minimum, or average value of each group of items. It can also show the total number of items in each group (count). The calculateOption specifies which of these options is used in the newly created column.

useFilter of type Boolean: Specifies whether or not to use the prGridfiltered as the grid to group. If useFilter is false, the main grid (prGrid) is used as the grid to group.

createGrid of type Boolean: Specifies whether or not to create a DataGrid of columns. Default is false.

Types of Aggregation: Sum, Average, Max, Min, Count, Distinct

public function getMaxValue(columnName:String):int

Description:
Gets a Max value from the numeric field of the column.

Parameters:
columnName of type String: Takes a column name of string type.

public function getMinValue(columnName:String):int

Description:
Gets a Min value from the numeric field of the column.

Parameters:
columnName of type String: Takes a column name of string type.

public function getRowValues(columnName:String,useFilter:Boolean):Array

Description:
Gets all the values in a selected column, even with repetitions. It returns an array of row values.

Parameters:
columnName of type String: Takes a column name of string type.

useFilter of type Boolean: Takes true to create a row of values in a selected column from the filtered grid.

public function getUniqueValues(columnName:String,useFilter:Boolean):Array

Description:
Gets all the unique values in a selected column. It returns an array type.

Parameters:
columnName of type String: Takes a column name of string type.

useFilter of type Boolean: Takes true to create a row of unique values in a selected column from the filtered grid.

public function resetFilter():void

Description:
Sets the original data to any DataGrid.


WebFOCUS