wt.enterprise.tabularresults
Class TabularQueryResultsService

java.lang.Object
  extended bywt.enterprise.tabularresults.TabularQueryResultsService
Direct Known Subclasses:
StdTemplateProcessor

public abstract class TabularQueryResultsService
extends Object

TabularQueryResultsService is a mapping from the HTML template calls and the services of a subclass of BasicQueryService, subclass of TableFormatService, and a subclass of DataFormatService. Ideally, this subclass should be used for presenting the results of a query in a table in an HTML webpage. However, the services of the subclass of BasicQueryService, subclass of TableFormatService, and a subclass of DataFormatService can be used for other purposes. To use TabularQueryResultsService to present the results of a query in a table in an HTML webpage, you need to do the following steps.

  1. Create a subclass of BaseQueryService to generate the queryresults you need ( you need to generate the code stub via Rose )
  2. Put the entry "getQuery QueryName=nameOfSubClass" where nameOfSubClass is the name of the subclass of BaseQueryService
  3. Put valid column names in the initialize method in nameOfSubClass or put an entry wt.property
  4. You need to set the name or an instance of the subclass of TableFormatService that want to use
  5. You also need to set the name or an instance of the subclass of DataFormatService that want to use
  6. Put in any customization lines in the HTML template
  7. put the line "printTable" as the last line in the HTML template.
The result will be a call to get the query in the subclass of BaseQueryService and a table where each row presents the data for each column relative to the context of the query result object for that row. Headers for each row are also printed out, again based on the column names either given by the subclass of BaseQueryService or retrieved in the initTable call in the subclass of TableFormatService and the context given by the objects that are returned from getQuery in the subclass of BaseQueryService. The individual cell entries are generated from a call to the subclass of DataFormatService using the context of the element of the queryresult for the current row and the column properties of the column the cell is in to generate the HTML string to put in the cell.

Supported API: false

Extendable: false

See Also:

Field Summary
private static String CODEBASE
           
protected  Object contextObj
          This is the context object that the call to the subclass of BaseQueryService will use to generate the query results
protected  DataFormatService dataFormatService
           
protected  String dataFormatServiceName
           
protected static String DEFAULT_DATAFORMAT_SERVICE
           
protected static String DEFAULT_QUERY_SERVICE
           
protected static String DEFAULT_TABLEFORMAT_SERVICE
           
protected  Object[] queryResults
          This is the array that the query results are cached into
protected  String queryServiceName
           
private static String RESOURCE
           
protected  TableFormatService tableFormatService
           
protected  String tableFormatServiceName
           
private static boolean VERBOSE
           
 
Constructor Summary
TabularQueryResultsService()
           
 
Method Summary
 void addColumn(Properties parameters, Locale locale, OutputStream os)
          This call will add a column to the table to be presented, only after the table initialized ( i.e.
 void deleteColumn(Properties parameters, Locale locale, OutputStream os)
          This call will delete an existing column that is to be presented in the table.
 Object getContextObj()
          Supported API: false
 DataFormatService getDataFormatService()
          Supported API: false
private  PrintWriter getPrintWriter(OutputStream os, Locale locale)
           
 void getQuery(Properties parameters, Locale locale, OutputStream os)
          This call arrives from the HTML template and should have the form "getQuery QueryName=nameOfSubClass" The value of nameOfSubClass can either be a full path name to a subclass of BaseQueryService or the name of the subclass.
 Object[] getQueryResults()
          Supported API: false
 TableFormatService getTableFormatService()
          Supported API: false
 boolean hasColumn(String columnID)
          Supported API: false
 Object loadClass(String className)
          Supported API: false
 void printFailedTableMessage(Throwable t, String key, Object[] params, Locale locale, OutputStream os)
          This method will be used to handle all exception error printing.
 void printTable(Properties parameters, Locale locale, OutputStream os)
          This is the call that actually prints out the table to the HTML template.
 void setAllColumnsProperties(Properties parameters, Locale locale, OutputStream os)
          This call will read any number of name value pairs and places them in each column currently defined .
 void setAllHeadersProperties(Properties parameters, Locale locale, OutputStream os)
          This call will read any number of name value pairs and places them in each column currently defined as header attributes.
 void setColumnProperties(Properties parameters, Locale locale, OutputStream os)
          This call will read any number of name value pairs and places them in the column defined by the ID tag.
 void setContextObj(Object context)
          Supported API: false
 void setDataFormatServiceName(String new_data_format_service_name)
          Supported API: false
 void setHeader(Properties parameters, Locale locale, OutputStream os)
          If the header of the column is to be set explicitly and the standard method of initializing the column header text is to overriden with the value specified in this call.
 void setHeaderProperties(Properties parameters, Locale locale, OutputStream os)
          This call will read any number of name value pairs and places them in the column defined by the ID tag as header attributes.
 void setQueryServiceName(String new_query_service_name)
          Supported API: false
 void setRowProperties(Properties parameters, Locale locale, OutputStream os)
          This call will read any number of name value pairs and places them in each rowProperties object .
 void setTableFormatServiceName(String new_table_format_service_name)
          Supported API: false
 void setTableProperties(Properties parameters, Locale locale, OutputStream os)
          This call will read any number of name value pairs and places them in tableProperties.
 void TabularQueryResultsService()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CODEBASE

private static String CODEBASE

VERBOSE

private static boolean VERBOSE

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

DEFAULT_QUERY_SERVICE

protected static String DEFAULT_QUERY_SERVICE

DEFAULT_TABLEFORMAT_SERVICE

protected static String DEFAULT_TABLEFORMAT_SERVICE

DEFAULT_DATAFORMAT_SERVICE

protected static String DEFAULT_DATAFORMAT_SERVICE

tableFormatServiceName

protected String tableFormatServiceName

queryServiceName

protected String queryServiceName

dataFormatServiceName

protected String dataFormatServiceName

tableFormatService

protected TableFormatService tableFormatService

dataFormatService

protected DataFormatService dataFormatService

queryResults

protected Object[] queryResults
This is the array that the query results are cached into


contextObj

protected Object contextObj
This is the context object that the call to the subclass of BaseQueryService will use to generate the query results

Constructor Detail

TabularQueryResultsService

public TabularQueryResultsService()
Method Detail

TabularQueryResultsService

public void TabularQueryResultsService()

setTableFormatServiceName

public void setTableFormatServiceName(String new_table_format_service_name)
Supported API: false


setQueryServiceName

public void setQueryServiceName(String new_query_service_name)
Supported API: false


setDataFormatServiceName

public void setDataFormatServiceName(String new_data_format_service_name)
Supported API: false


getTableFormatService

public TableFormatService getTableFormatService()
Supported API: false


getDataFormatService

public DataFormatService getDataFormatService()
Supported API: false


setContextObj

public void setContextObj(Object context)
Supported API: false


getContextObj

public Object getContextObj()
Supported API: false


getQueryResults

public Object[] getQueryResults()
Supported API: false


hasColumn

public boolean hasColumn(String columnID)
Supported API: false


getQuery

public void getQuery(Properties parameters,
                     Locale locale,
                     OutputStream os)
              throws WTException
This call arrives from the HTML template and should have the form "getQuery QueryName=nameOfSubClass" The value of nameOfSubClass can either be a full path name to a subclass of BaseQueryService or the name of the subclass. Either way, the name has to reference a subclass of BaseQueryService. The resulting call will get a queryresult and transfer the queryresult into an array that is cached while the table is generated and printed out. The subclass of TableFormatService is instantiated here and the table object is initialized. Should any part of getting the query or initializing the subclass of TableFormatService fail, an exception is generated and an error message is printed out to the HTML webpage.

Supported API: false

Throws:
WTException

addColumn

public void addColumn(Properties parameters,
                      Locale locale,
                      OutputStream os)
               throws WTException
This call will add a column to the table to be presented, only after the table initialized ( i.e. the call to getQuery ). The column ID had to be specified and the name of the property to present must be a valid name for the type of object that the column is presenting relative to the subclass of DataFormatService that is being used.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page
Throws:
WTException

deleteColumn

public void deleteColumn(Properties parameters,
                         Locale locale,
                         OutputStream os)
                  throws WTException
This call will delete an existing column that is to be presented in the table. The ID of the column has to be specified and valid. If the ID of the column is NOT specified or NOT valid then an exception is thrown and a message is to printed to the HTML page and a printStackTrace is performed.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page
Throws:
WTException

setTableProperties

public void setTableProperties(Properties parameters,
                               Locale locale,
                               OutputStream os)
This call will read any number of name value pairs and places them in tableProperties. These properties are then used in the tag. Note, only entries that match the the set of supported HTML attributes are retrieved from tableProperties. Invalid table attributes are ignored.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page

setColumnProperties

public void setColumnProperties(Properties parameters,
                                Locale locale,
                                OutputStream os)
                         throws WTException
This call will read any number of name value pairs and places them in the column defined by the ID tag. If the ID tag is not specified or there is NOT any column with that ID an exception is thrown and printStackTrace is called and an error message is printed to the web page. If column ID is valid, the properties are then given to the column specified. These properties are then used in the
tag if they match any of the supported HTML attributes for TR.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page

printTable

public void printTable(Properties parameters,
                       Locale locale,
                       OutputStream os)
This is the call that actually prints out the table to the HTML template. It goes through the process of initializing the tags that will appear in the table ( e.g. the TABLE, TR, TH, and TD tags ) and then loops over the entries in the array that was returned from the query. For element in the array from the query, a row is generated by looping over the rows ( both default and those added in the WindChill script ) and printing out a table cell for each column in each row. The entry in the table cell is determined by the column attributes, the context of the query result, and the DataFormatService used.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page

loadClass

public Object loadClass(String className)
Supported API: false


printFailedTableMessage

public void printFailedTableMessage(Throwable t,
                                    String key,
                                    Object[] params,
                                    Locale locale,
                                    OutputStream os)
This method will be used to handle all exception error printing. It will print the stackTrace of the exception and it will also print a localized message to the web page.

Supported API: false

Parameters:
t - The actual exception that was thrown
key - The "key" for getting the localized message from the resource bundle
locale - The locale object to be used to localize the message for the browser
os - The output stream to the HTML template page

getPrintWriter

private PrintWriter getPrintWriter(OutputStream os,
                                   Locale locale)

tag if they match any of the supported HTML attributes for TD and any parameters to be passed to the subclass of DataFormatService being used are passed in the same properties object.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page
Throws:
WTException

setAllColumnsProperties

public void setAllColumnsProperties(Properties parameters,
                                    Locale locale,
                                    OutputStream os)
This call will read any number of name value pairs and places them in each column currently defined . These properties are then used in the
tag if they match any of the supported HTML attributes for TD and any parameters to be passed to the subclass of DataFormatService being used are passed in the same properties object.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page

setHeaderProperties

public void setHeaderProperties(Properties parameters,
                                Locale locale,
                                OutputStream os)
                         throws WTException
This call will read any number of name value pairs and places them in the column defined by the ID tag as header attributes. That is, the attributes will only be used in the display of the header, but not any of the row after the header. If the ID tag is not specified or there is NOT any column with that ID an exception is thrown and printStackTrace is called and an error message is printed to the web page. If column ID is valid, the properties are then given to the column specified. These properties are then used in the
tag if they match any of the supported HTML attributes for TH and any parameters to be passed to the subclass of DataFormatService being used are passed in the same properties object.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page
Throws:
WTException

setAllHeadersProperties

public void setAllHeadersProperties(Properties parameters,
                                    Locale locale,
                                    OutputStream os)
This call will read any number of name value pairs and places them in each column currently defined as header attributes. That is, the attributes will only be used in the display of the header, but not any of the row after the header. These properties are then used in the
tag if they match any of the supported HTML attributes for TH and any parameters to be passed to the subclass of DataFormatService being used are passed in the same properties object.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page

setHeader

public void setHeader(Properties parameters,
                      Locale locale,
                      OutputStream os)
               throws WTException
If the header of the column is to be set explicitly and the standard method of initializing the column header text is to overriden with the value specified in this call. If the ID tag is not specified or there is NOT any column with that ID an exception is thrown and printStackTrace is called and an error message is printed to the web page.

Supported API: false

Parameters:
parameters - The parameters read from the WindChill script
locale - The locale to use when generating location specific text
os - The output stream to the HTML page
Throws:
WTException

setRowProperties

public void setRowProperties(Properties parameters,
                             Locale locale,
                             OutputStream os)
This call will read any number of name value pairs and places them in each rowProperties object . These properties are then used in the