atg.droplet.sql
Class SQLQueryForEach

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.TimedOperationService
              extended by atg.nucleus.servlet.ServletService
                  extended by atg.nucleus.servlet.HttpServletService
                      extended by atg.servlet.DynamoServlet
                          extended by atg.droplet.ForEach
                              extended by atg.droplet.sql.SQLQueryForEach
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, ParameterServlet, java.util.EventListener, javax.servlet.Servlet

public class SQLQueryForEach
extends ForEach

This servlet executes a SQL query and renders its output parameter for each element returned by the query. The query can either be specified as a reference to an SQLQuery bean, or it can be specified inline with parameters.

For each row returned by the query, we set the following parameters:

index
The 0-based index of the returned row
count
The 1-based number of the returned row
element
A dynamic bean that has properties for accessing the values returned in the result set. You can access the values either by name or by column index. The name refers to either the column name or the column alias if one was used in the query. To access values by name, you say: "element.name". To access values by column index, you say: element.columns[i] where "i" is the 0-based index of the returned column.

As mentioned before, there are two ways that you can specify a query to the SQLQueryForEach droplet. You can refer to an existing SQLQuery bean using the queryBean parameter. For example, you might say:

   <param name="queryBean" value="bean:/mySite/MySQLQuery">
 

Alternatively, you can specify the SQL directly in the jhtml file with the querySQL parameter. In this case, you also have to specify the values of the "dataSource" and "transactionManager" parameters. Thus your droplet declaration would include the following parameters:

   <param name="myAge" value="bean:MyUser.age">
   <param name="querySQL" value="select * from person where age=:myAge">
   <param name="dataSource" value="bean:/atg/dynamo/service/jdbc/JTDataSource">>
   <param name="transactionManager" value="bean:/atg/dynamo/transaction/TransactionManager">>
 
The values for the ":name" constructs in your query are taken from the parameters in your request. You can also define a set of output parameters which you can use to control the formatting for the returned results:
outputStart
This parameter is rendered before any output tags if the array is not empty.
outputEnd
This parameter is rendered after all output tags if the array is not empty.
output
This parameter is rendered for once for each element in the array.
empty
This optional parameter is rendered if the array contains no elements.
error
This optional parameter is rendered if there was an error executing the query.


Field Summary
static java.lang.String CLASS_VERSION
           
 
Fields inherited from class atg.droplet.ForEach
ARRAY, COUNT, DEBUG, ELEMENT, ELEMENT_NAME, EMPTY, INDEX, INDEX_NAME, KEY, OUTPUT, OUTPUT_END, OUTPUT_START, REVERSE_ORDER, SIZE, SORT_PROPERTIES
 
Fields inherited from class atg.servlet.DynamoServlet
mAllowCleanupRequest, mParameters
 
Fields inherited from class atg.nucleus.servlet.ServletService
SERVLET_INFO_KEY
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
SQLQueryForEach()
           
 
Method Summary
 java.lang.Object getArray(DynamoHttpServletRequest pReq)
          Returns the enumeration from the SQLQuery that contains the elements in the result set
 void service(DynamoHttpServletRequest pReq, DynamoHttpServletResponse pRes)
          Renders the list of items retrieved by the query
 
Methods inherited from class atg.droplet.ForEach
getSortedArray, serviceArray, serviceCollection, serviceDictionary, serviceEnumeration, serviceIndexedList, serviceIterator, serviceMap, serviceMapArray, servicePrimitiveArray, setElementParameter
 
Methods inherited from class atg.servlet.DynamoServlet
doDelete, doGet, doPost, doPut, getParameter, getParameters, getServletContext, service, service, setParameter
 
Methods inherited from class atg.nucleus.servlet.ServletService
destroy, getServletConfig, getServletInfo, init, setServletInfo
 
Methods inherited from class atg.nucleus.TimedOperationService
getAverageRequestHandlingTime, getHandledRequestCount, getRequestStartTime, getTotalRequestHandlingTime, isKeepingStatistics, notifyHandledRequest, resetStatistics, setKeepingStatistics
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

SQLQueryForEach

public SQLQueryForEach()
Method Detail

getArray

public java.lang.Object getArray(DynamoHttpServletRequest pReq)
Returns the enumeration from the SQLQuery that contains the elements in the result set

Overrides:
getArray in class ForEach

service

public void service(DynamoHttpServletRequest pReq,
                    DynamoHttpServletResponse pRes)
             throws javax.servlet.ServletException,
                    java.io.IOException
Renders the list of items retrieved by the query

Overrides:
service in class ForEach
Parameters:
pReq - the request to be processed
pRes - the response object for this request
Throws:
javax.servlet.ServletException - an application specific error occurred processing this request
java.io.IOException - an error occurred reading data from the request or writing data to the response.