# <netui-data:callControl> Tag

This tag is used to call a method on a control file (either a JCS or JCX file).

## Syntax

<netui-data:callControl
controlId="string_controlId"
[failOnError="boolean_failOnError"]
method="string_method"
[resultId="string_resultId"] />

## Description

This tag is used to call a method on a control file (either a JCS or JCX file).

The `controlId` attribute is used to specify the control file to be called. The value returned by the method will be set in the {pageContext...} data binding context under the attribute specified by the `resultId` attribute.

For example, if you call a control with the following <netui-data:callControl> tag...

        <netui-data:callControl
              controlId="helloWorldControl"
              method="hello"
              resultId="helloMessage"
              />

...the result of the call is stored in the {pageContext...} data binding context under the attribute `helloMessage`.

The result can be retrieved with the data binding expression {pageContext.helloMessage}

       <netui:label value="{pageContext.helloMessage}"/>

In a scriptlet, the result can be retrieved by calling the `getAttribute()` method on the javax.servlet.jsp.PageContext object:

        <%= pageContext.getAttribute("helloMessage") %>

The <netui-data:callControl> tag must be used in conjunction with the <netui-data:declareControl> tag. The <netui-data:declareControl> tag is used to give the control a `controlId`:

        <netui-data:declareControl
              type="tagSamples.netui_databinding.callControl.HelloWorldControl"
              controlId="helloWorldControl"
              />

Then the <netui-data:callControl> refers to the control using that `controlId`:

        <netui-data:callControl
              controlId="helloWorldControl"
              method="hello"
              resultId="helloMessage"
              />

Note that only synchronous methods can be called with <netui:callControl>. For handling asynchronous methods see the help topic Calling Web Services and Custom Java Controls From A Page Flow

## Attributes

controlId | The control on which to invoke a method. This value must already be specified in a <netui-data:declareControl> tag.
Required | Supports runtime expression evaluation | Data bindable
Yes | No | Yes
failOnError | Boolean. If set to true, any errors occuring while invoking the control method will be be reported in-line on the JSP page.
Required | Supports runtime expression evaluation | Data bindable
No | No | No
method | The name of the method to invoke
Required | Supports runtime expression evaluation | Data bindable
Yes | No | No
resultId | The data returned by the method is loaded into the PageContext object, under this property name.
Required | Supports runtime expression evaluation | Data bindable
No | No | No

## Sample

In this sample, a JSP page uses a <netui-data:declareControl> tag to declare a control. Then the <netui-data:callControl> tag calls the `insertProduct` method on that control. The `insertProduct` method is called with parameters, provided by <netui-data:methodParameter> tags.

        <netui-data:declareControl type="dbControls.ProductsDBControl" controlId="productsDBControl"/>

        <netui-data:callControl controlId="productsDBControl" method="insertProduct">
            <netui-data:methodParameter value="1"/>
            <netui-data:methodParameter value='ACME RacePro Crankset'/>
            <netui-data:methodParameter value="280.00"/>
            <netui-data:methodParameter value="acme_racepro_crankset.jpg"/>
            <netui-data:methodParameter value="true"/>
        </netui-data:callControl>

## Code Sample

[BEA_HOME]/weblogic81/samples/workshop/SamplesApp/tagSamples/netui_databinding/callControl/callControl.jsp

## Related Topics

<netui-data:callControl> Tag Sample

<netui-data:methodParameter> Tag

<netui-data:callMethod> Tag

<netui-data:callPageFlow> Tag