Tags:
create new tag
, view all tags

XEO XWC Data List Connectors

Data List connectors in XEO are responsible for retrieving information from the Data Repositories used in a project and made this data available to XEO Web Components or Java Code. They are tightly coupled with XEO Web Components like: xvw:gridPanel, xvw:gridExplorer, xeo:gridPanel and xeo:gridExplorer.

This connectors are implementations of Java Interfaces defined in the XWC project. Each one of this Java Interfaces give to the existent connectors certain features and behaviours (not all the connectors have all the features), this interfaces are:

There are other interfaces used by those ones, that also need to be implemented to develop a connector (Metadata, Iterator, Record...).

Three different connectors are available to the developers:

XEOObjectListConnector

(netgest.bo.xwc.components.connectors.XEOObjectListConnector)

This connector is responsible to retrieve data from a XEO Data Repository. Its totally integrated with the API defined in XEO.Core to deal with XEO Objects ( boObjectList and boObject). Web Components like xeo:gridPanel and xeo:gridExplorer are dependent of this connector and use it to present List's of XEO Objects in a viewer. Components like xvw:gridPanel and xvw:gridExplorer can also use this connector to present lists (dataSource property), but they're not dependant on this particular connector.

Implements all the features available to the connectors (Pagination, Sort, Filter, Grouping, Aggregration, FullTextSearch...)

It can also be used in Java Code not connected to any particular Web Component, this usage its not common, but all the connectors have this ability.

Example:

DataListConnector listEboClsReg = XEOObjectListConnector(boObjectList.list(this.getEboContext(), 
   "Select Ebo_ClsReg"));

Iterator itClsReg= listEboClsReg.iterator(); 

while (itClsReg.hasNext()) {

//YOUR CODE

}

SQLDataListConnector

(netgest.bo.xwc.components.connectors.sql.SQLDataListConnector)

It provides the ability to retrieve data from any SQL database using a SQL Query. It can be used in xvw:gridPanel and xvw:gridExplorer to present List's of information to Users. It implements the features available in the DataListConnector interface (except FullTextSearch).

Example:

(Bean)

import netgest.bo.xwc.components.connectors.DataListConnector;
import netgest.bo.xwc.components.connectors.sql.SQLDataListConnector;
import netgest.bo.xwc.xeo.beans.XEOBaseBean;
 
public class SQLListBean extends XEOBaseBean {
 
   private DataListConnector conn=null;
 
   public DataListConnector getList()  {
      if (conn==null)
         conn = new SQLDataListConnector("select name,label,phisicaltable,sys_dtcreate," +
            "xeopackage$ from ebo_clsreg");
      return conn;
   }
}

In a Bean the only argument needed is the query to be executed. This uses the default Database Connection used in XEO, if a different one is required, then SQLDataListConnector needs to be extended and the method getConnection has to be reimplemented to return the desired Connection.

(Viewer)

<xvw:gridPanel renderToolBar="false" rowSelectionMode="SELECTION_ROW" enableHeaderMenu="true"
  dataSource="#{viewBean.list}">
  <xvw:columns>
    <xvw:columnAttribute width="40" dataField="NAME"/>
    <xvw:columnAttribute width="40" dataField="LABEL" />
    <xvw:columnAttribute width="40" dataField="PHISICALTABLE" />
    <xvw:columnAttribute width="40" dataField="SYS_DTCREATE" />
    <xvw:columnAttribute width="40" dataField="XEOPACKAGE$" />
  </xvw:columns>
</xvw:gridPanel>

GenericDataListConnector

(netgest.bo.xwc.components.connectors.generic.GenericDataListConnector)

Provides the ability to present data from any Data Repository on a XWC Viewer using xvw:gridPanel or xvw:gridExplorer components. It can be used to retrieve data for example from a WebService, noSQL databases and any other system, that have Java API's to expose the data.

By default it only has the ability to provide local sorts and local filters (in memory).

This connector always need to be extended in order to use it. The metadata for the columns of data retrieved need to by added to the metainformation of the connector and the Rows of data retrieved also need to be added to the connector internal structures.

Example:

public class ExampleGenericDataListConnector extends GenericDataListConnector {
 
   public ExampleGenericDataListConnector() {
      super();
      this.createColumn("COL1", "Column 1",DataFieldTypes.VALUE_CHAR );
      this.createColumn("COL2","Column 2",DataFieldTypes.VALUE_DATE);
   }
 
   @Override
   public void refresh() {
      super.refresh();
      //DUMMY CODE TO GET THE DATA FROM THE REPOSITORY X
      Record [] datarecords= APIX.getDataRecords();
      for (int i = 0; i <  datarecords.length; i++) {
         this.createRow();
         this.createRowAttribute("COL1",datarecords[i].getCol1());
         this.createRowAttribute("COL2", datarecords[i].getCol2());
      }
   }
}

After that this class can be used on beans and connected to xvw:gridPanel or xvw:gridExplorer (the same way as the SQLDataListConnector example)to show the data to end users.

-- AntonioCruz - 05 Dec 2012

Topic revision: r2 - 2012-12-05 - AntonioCruz
 

No permission to view TWiki.WebTopBar

This site is powered by the TWiki collaboration platform Powered by Perl

No permission to view TWiki.WebBottomBar