Manipulating and Displaying Multiple Groups in the VDB
When Info*Engine queries databases and data repositories, it places the results of the queries in the VDB. In most cases, the last group in the VDB is the one needed for display in the web browser. However, all groups generated through a JSP page are available to other webjects on the page, and possibly to other webjects called on other pages in the session (depending on the scope set). This includes those standalone tasks that are executed through the JSP engine.
For standalone tasks, Info*Engine always makes this last group created through the task available for manipulation. The other groups retrieved by the task prior to the last group still exist in the VDB, but are not accessible without the use of the Return-Groups webject:
<ie:webject name="Return-Groups" type="GRP">
<ie:param name="GROUP_IN" data="group_names"/>
</ie:webject>
Using an example similar to the employee example described previously, the following scenario demonstrates how to obtain a separate lists of employees from the sales department and the development department of a company and then, unlike the previous example, displays each employee list, rather than displaying a combined list of employees.
To accomplish this, author an Info*Engine task named “listseparate” that queries a database for information about sales employees and development employees. The two Query-Objects webjects necessary to retrieve these two lists are the same webjects that were used in the previous example:
<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="com.myHost.Adapter"/>
<ie:param name="CLASS" data="salesemp"/>
<ie:param name="WHERE" data="()"/>
<ie:param name="GROUP_OUT" data="sales"/>
</ie:webject>
<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="com.myHost.Adapter"/>
<ie:param name="CLASS" data="devemp"/>
<ie:param name="WHERE" data="()"/>
<ie:param name="GROUP_OUT" data="development"/>
</ie:webject>
As before, the first Query-Objects webject asks for information about employees from the sales employee table and the second Query-Objects webject asks for information from the development employee table. The results of the queries are then placed in the sales and development groups.
To execute the “listseparate” task and then view the two employee lists that are stored in the sales and development groups, you can create a JSP page. On the page, use the Info*Engine custom task tag to execute the task and include two display webjects to display the groups. By default, the task executes in the same JVM as the JSP engine that is processing the JSP page. Therefore, all of the groups created through the task are available to the webjects that execute after the task executes.
The task tag and display webjects that are designed to display both groups might look like this:
<ie:task uri="listseparate.xml"/>
<ie:webject name="Display-Table" type="DSP">
<ie:param name="GROUP_IN" data="sales"/>
<ie:param name="BORDER" data="1"/>
<ie:param name="ATTRIBUTE"
data="ename,department,phone,title" delim=","/>
<ie:param name="HEADER"
data="Name,Department,Telephone,Title" delim=","/>
</ie:webject>
<ie:webject name="Display-Table" type="DSP">
<ie:param name="GROUP_IN" data="development"/>
<ie:param name="BORDER" data="1"/>
<ie:param name="ATTRIBUTE"
data="ename,department,phone,title" delim=","/>
<ie:param name="HEADER"
data="Name,Department,Telephone,Title" delim=","/>
</ie:webject>
Notice that the task tag executes the “listseparate” task. After the task completes, both groups are available. The first Display-Table webject displays the sales group, which is specified in its GROUP_IN parameter. The second Display-Table webject displays the development group, which is specified in its GROUP_IN parameter. The resulting tables are similar to the following:
Putting the two Query-Objects webjects in a task separates the queries from the display as far as your code is concerned, but in this case, the resulting task execution takes place as if the Query-Objects webjects were on the same JSP page as the display webjects.
If you execute the “listseparate” task outside of the JVM where the JSP engine resides, then not all of the groups generated by the task are automatically available to the JSP page. Only the last group generated is automatically available. You can expand the “listseparate” task so that it returns more than the last group by adding the Return-Groups webject after the two query webjects. The “listseparate” task must end in a Return-Groups webject so that both groups are available to the calling task or JSP. The Return-Groups webject might look like this:
<ie:webject name="Return-Groups" type="GRP">
<ie:param name="GROUP_IN" data="sales"/>
<ie:param name="GROUP_IN" data="development"/>
</ie:webject>
In the Return-Groups webject, you can include multiple GROUP_IN parameters. Each of these parameters defines a particular group in the VDB that you want to have returned for further processing. A parameter value of “ * ” causes all groups in the task’s VDB to be returned.
To execute the “listseparate” task outside of the JVM where the JSP engine resides, specify the processor attribute on the task tag in the JSP page. For example, if the task processor has the default name of “com.myCompany.server.taskProcessor” you can include the processor attribute in the task tag as follows:
<ie:task uri="listseparate.xml" processor="com.myCompany.server.
taskProcessor"/>
You can choose to execute tasks outside of the JVM where the JSP engine resides for performance reasons or for some other reason. Remember that whenever you do specify the processor, you must ensure that the task named returns all of the groups that are needed by the other webjects on the JSP page.