9.3 RFI Example
The RFI Example illustrates how to use the RFI Service to receive a RFIDataSource object from the remote JSM server. The contents of this data source are displayed using the RFI Example Viewer.
Properties properties = new Properties ();
properties.put ( "rfi.server", "http://your.own.url:port" ) ;
RFIService service = RFIService.getInstance ( properties ) ;
RFIDataSource dataSource = (RFIDataSource)service.getObject ( "EMPLOYEE-FETCH" ) ;
if ( dataSource == null )
{
printStream.println ( "No object was returned" ) ;
return ;
}
if ( dataSource.equals ( "EMPLOYEE" ) )
{
printStream.println ( "Data source fields :" ) ;
printStream.println ( "" ) ;
/*
Access fields
*/
String[] fields = dataSource.getFieldNames () ;
for ( int i=0; i < fields.length; i++ )
{
printStream.println ( fields[i] + "\t\t" + dataSource.getFieldValue ( fields[i] ) ) ;
}
printStream.println ( "" ) ;
if ( dataSource.containsTable ( "SKILLS" ) )
{
printStream.println ( "Data source table : SKILLS" ) ;
printStream.println ( "" ) ;
/*
Access table
*/
RFIDataTable table = dataSource.getTable ( "SKILLS" ) ;
/*
Access table columns
*/
String[] columns = table.getColumns () ;
for ( int i=0; i < columns.length; i++ )
{
printStream.print ( columns[i] + "\t" ) ;
}
/*
Access table rows
*/
int rowCount = table.getRowCount () ;
for ( int i=0; i < rowCount; i++ )
{
printStream.println ( "" ) ;
for ( int j=0; j < columns.length; j++ )
{
printStream.print ( table.getValueAt ( i, j ) + "\t" ) ;
}
}
}
}