ClassName

atg.repository.servlet.RQLQueryForEach

Component

/atg/dynamo/droplet/RQLQueryForEach

The RQLQueryForEach servlet bean executes a RQL query and renders its output open parameter once for each element returned by the query. The query can be a simple query or can include parameters. Note that the syntax for specifying a parameter is different from the syntax normally used in RQL. For example, you might want to issue this RQL query:

age > ?0

In the RQLQueryForEach servlet bean, the query can be specified like this:

<dsp:param name="queryRQL" value="age > :whatAge"/>

The value for the whatAge argument is supplied through a parameter. For example, the link to the page containing the servlet bean might be:

<dsp:a href="http://www.example.com/over35.jsp">Click here if you are
over 35<dsp:param name="whatAge" value="35"/>
</dsp:a>

For more information about RQL, see the RepositoryQueries chapter of the ATG Repository Guide.

Input Parameters

repository
The repository to query.

itemDescriptor
The name of the item type to query.

queryRQL
The RQL query to execute.

transactionManager
The Transaction Manager to use (optional). For example:

<dsp:param name="transactionManager"
  bean="/atg/dynamo/transaction/TransactionManager"/>

sortProperties
This optional parameter holds a string that specifies the order the items in the array are rendered. The syntax of this parameter depends on the type of item in the array: JavaBeans, Dynamic Beans, or on Dates, Numbers, or Strings.

To sort on the properties of a JavaBean, specify the value of sortProperties as a comma-separated list of property names. You can sort on as many properties as you like. The first property name specifies the primary sort, the second property name specifies the secondary sort, and so on. Use + followed by a property name to indicate that items in the array should be sorted in ascending order and followed by the property name to indicate descending order.

For example, to sort an array of JavaBeans first by an alphabetical ordering of title and then by descending order of size, use this input parameter:

<dsp:param name="sortProperties" value="+title,size"/>

If your array consists of Dates, Numbers, or Strings, specify the value of sortProperties with either a single + or a single to indicate ascending or descending order respectively.

For example, to sort an output array of Strings in alphabetical order:

<dsp:param name="sortProperties" value="+"/>

When you are sorting elements of a Map, and you want to sort by the key, set the value to the ascending/descending indicator followed by an underscore and the term key:

<dsp:param name="sortProperties" value="_key"/>

When one servlet bean is nested in another and both accept the sortProperties parameter, the child servlet bean inherits the sortProperties setting applied by the enclosing servlet bean unless the child specifies another sortProperties setting or is assigned an empty value:

<dsp:param name="sortProperties" value=""/>

Output 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. To return a particular property value for each item in the result set, use the convention element.name, where name is any property name supported by the item descriptor.

repositoryException
If a RepositoryException is thrown, this parameter is set to the exception.

Open Parameters

The following open parameters control the formatting for the returned results:

output
This parameter is rendered once for each element in the array.

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.

empty
This optional parameter is rendered if the array contains no elements.

error
This optional parameter is rendered if there is an error when the query executes.

Example

This example uses the RQLQueryForEach servlet bean to display a list of all users in the Personalization profile repository whose profiles indicate they are eligible to receive email.

<p>The following customers are eligible to receive email:

<dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach">
  <dsp:param name="queryRQL" value="receiveEmail=true"/>
  <dsp:param name="repository"
  value="/atg/userprofiling/ProfileAdapterRepository"/>
  <dsp:param name="itemDescriptor" value="user"/>
  <dsp:oparam name="output">
    <p><dsp:valueof param="element.lastName"/>
  </dsp:oparam>
</dsp:droplet>
 
loading table of contents...