Specifies a RelationalView and subview, executes a query, and passes the results of that query to another servlet bean such as ForEach for display.

Class Name

atg.rview.RelationalViewDroplet

Component

/atg/dynamo/service/jdbc/RelationalViewDroplet

Required Input Parameters

Set one of the following input parameters:

rviewName

The name of the RelationalView to display.

rview

Instead of specifying the name of a RelationalView in rviewName, use this parameter to pass the RelationalView to use. The value of this parameter usually comes from the property of some object, or from some other parameter. The RelationalView can be a top-level view, or a subview.

This is very handy for printing out the elements of a relationship. A relationship is represented by a property that is itself a RelationalView. In our example, for each Person you might also want to print the person’s Interests. Inside the ForEach servlet bean, you have another call to a RelationalView that accesses the interests property of the row:

<table border>
  <tr><th>id</th><th>name</th><th>age</th></tr><tr>interests<>

  <dsp:droplet name="ForEach">
    <dsp:param name="array" param="result"/>
    <dsp:oparam name="output">
      <tr>
        <td><dsp:valueof param="element.id"/></td>
        <td><dsp:valueof param="element.name"/></td>
        <td><dsp:valueof param="element.age"/></td>

        <td>
          <dsp:droplet name="RelationalViewDroplet">
            <dsp:param name="rview" param="element.interests"/>
            <dsp:oparam name="output">
              <dsp:droplet name="ForEach">
                <dsp:param name="array" param="result"/>
                <dsp:oparam name="output">
                  <dsp:valueof param="element.interest"/>
                </dsp:oparam>
              </dsp:droplet>
            </dsp:oparam>
          </dsp:droplet>
        </td>

      </tr>
    </dsp:oparam>
  </dsp:droplet>

</table>

Optional Input Parameters

subviewName

The name of the subview to display. If you supply this parameter, you must also set rviewName. Subview parameters are set in one or more subviewParam parameters. For example:

<dsp:droplet bean="RelationalViewDroplet">
  <dsp:param name="rviewName" value="PersonRview"/>
  <dsp:param name="subviewName" value="byId"/>
  <dsp:param name="subviewParam0" param="personId"/>

Type restrictions on subviews apply. For example, the byId expects a parameter of type int.

subviewParam

The parameters to supply to the subview specified by the input parameter subviewName, in the following format:

subviewParam0
subviewParam1
...

operation

Specifies which form of the select call to execute, and determines what form the result parameter takes, with one of the following settings:

firstRow

Used if the operation parameter is set to select, or is unset; specifies how many rows to skip before starting the array results. If the parameter’s value is a String, it is converted to an integer.

rowCount

Used only if the operation is select (the default); specifies the maximum number of rows to place into the array of results.

functionName

The name of the query function to invoke, instead of calling one of the operations on a RelationalView. Function parameters are supplied by one or more functionParam input parameters (below). As with the subviews, the values of these parameters must be of types that are valid for the function. See subviewName and subviewParam, above. Setting the functionName and functionParam parameters supersedes any settings for parameters subview, operation, firstRow, and rowCount.

functionParam

The parameters to supply to the query function specified by input parameter functionName, in the following format:

functionParam0
functionParam1
...

resultName

Normally, the result of the RelationalView operation is placed into a parameter called result. You might want to change the name of this parameter. If so, set resultName to the name of the parameter in which to place the results.

Output Parameters

result

The result of the RelationalView operation. If resultName is set, then its value is used instead.

errorMessage

If an error occurs during the RelationalView operation, set to the text of the corresponding error message.

Open Parameters

output

Rendered after RelationalViewDroplet executes and places the results in the result parameter or the parameter specified by resultName.

errorOutput

Rendered instead of the output parameter if an error occurs while the RelationalViewDroplet is performing its operation. The output parameter errorMessage contains the error message.

Usage Notes

An HTML application often lists the results of a database query. In Relational Views terms, this means finding the proper RelationalView or subview, calling select on that RelationalView, and printing the resulting array.

RelationalViewDroplet allows a .jsp page to specify a RelationalView and subview, execute a query, then pass the results of that query to another servlet bean such as ForEach for display. All this can be done without any Java code.

Example

The following example shows a .jsp page that obtains all rows from the PersonRview RelationalView, then uses ForEach to display each row in a table:

<dsp:importbean bean="/atg/dynamo/service/jdbc/RelationalViewDroplet"/>
<dsp:importbean bean="/atg/dynamo/droplet/ForEach"/>

<html>
<head></head>
<body>

<dsp:droplet name="RelationalViewDroplet">
  <dsp:param name="rviewName" value="PersonRview"/>
  <dsp:oparam name="output">
    <table border>
      <tr><th>id</th><th>name</th><th>age</th></tr>

      <dsp:droplet name="ForEach">
        <dsp:param name="array" param="result"/>
        <dsp:oparam name="output">
          <tr>
            <td><dsp:valueof param="element.id"/></td>
            <td><dsp:valueof param="element.name"/></td>
            <td><dsp:valueof param="element.age"/></td>
          </tr>
        </dsp:oparam>
      </dsp:droplet>

    </table>
  </dsp:oparam>
</dsp:droplet>

</body>
</html>

In this example, two parameters are passed to RelationalViewDroplet: rviewName and output, where rviewName is set to the name of the RelationalView. The servlet bean calls select on that RelationalView, puts the array of rows into a parameter called result, then displays the output parameter. The output parameter displays a table and uses ForEach to iterate over each element of the result array, displaying one table row for each array element.

 
loading table of contents...