You can use the atg.integrations.MapRPCDroplet servlet bean to execute RPC commands in JavaServer Pages. This servlet bean executes a command and, depending on whether the command is executed successfully, renders either its output open parameter or its error open parameter. If the command is executed successfully, the result output parameter is set to the result of the command, and the output open parameter is rendered. If an exception is thrown, the exception output parameter is set to the exception, and the error open parameter is rendered.

The command input parameter takes an object that implements the atg.integrations.Command interface. The inputParameters parameter supplies the inputs to the command as a java.util.Map of parameter name/value pairs.

As an alternative to specifying these values in pages, MapRPCDroplet has command and inputParameters properties that you can use to specify these values in the servlet bean’s properties file. Note, however, that you cannot specify the same parameter both in the properties file and in a page. If you do this, MapRPCDroplet throws a ServletException.

MapRPCDroplet also takes an inputParameterNames parameter that you can use to specify the input names as a list of page parameters, and then use those page parameters to specify the input values. For example:

<dsp:param name="inputParameterNames" value="first_name,age"/>
<dsp:param name="first_name" value="Bill"/>
<dsp:param name="age" value="43"/>

You cannot include both the inputParameters and the inputParameterNames parameter in the same page, or include inputParameterNames in the page if inputParameters is specified in the servlet bean’s properties file.

However, there is a way you can specify default values for the command parameters in the servlet bean’s properties file, and then optionally override these values in pages. To do this:

The values specified for the page parameters override the values in the properties file, and are used when the command is invoked. If a command parameter has no corresponding page parameter, the default value from the properties file is used.

Input Parameters
Output Parameters
Open Parameters
Example

The following example uses inputParameterNames to create a UserId page parameter, and then sets its value to the value of a profile ID. This parameter name/value pair is passed as an input to the command. Depending on whether the command is executed successfully, Dynamo renders either the output open parameter or the error open parameter.

<dsp:droplet bean="/atg/integrations/MapRPCDroplet">
 <dsp:param name="command"
 value="bean:/atg/integrations/jdbc/QueryForUser"/>
 <dsp:param name="inputParameterNames" value="UserId"/>
 <dsp:param name="UserId" value="bean:Profile.Id"/>

 <dsp:oparam name="output">
 <p>The user's email address is:
 <dsp:valueof param="result.emailAddress"/>
 </dsp:oparam>

 <dsp:oparam name="error">
 <p>Unable to execute query. The following exceptions occurred:
 <dsp:valueof param="exception"/>
 </dsp:oparam>

</dsp:droplet>