# Creating a New Application View Control

This topic describes how to create a new Application View control.

To learn about Application View controls, see Application View Control.

To learn about WebLogic Workshop controls, see Using Controls in Business Processes.

To create a new Application View control:

1. Click Add on the Controls tab to display a list of controls that represent the resources with which your business process can interact.

Note: If the Controls tab is not visible in WebLogic Workshop, click View —> Windows —> Data Palette from the menu bar.

2. Choose Integration Controls to display the list of controls used for integrating applications.
3. Choose ApplicationView to display the Insert ApplicationView dialog.
4. In the Variable name for this control field, type the variable name used to access the new Application View control instance from your business process. The name you enter must be a valid Java identifier.
5. In the Step 2 pane, choose the Create a new ApplicationView control to use radio button.
6. In the New JCX name field, type the name of your new JCX file. The .jcx filename extension is automatically appended to the name you enter.
7. Decide whether you want to make this a control factory and select or clear the Make this a control factory that can create multiple instances at runtime check box. For more information about control factories, see Control Factories: Managing Collections of Controls.
8. In the Step 3 pane, click Browse... The Application Views Browser dialog opens, displaying application views that are published in the current domain. Application views that have not been published using the Application Integration Design Console do not appear in the list.
9. Select the published application view you want this Application View control to represent. Services offered by the selected application view are displayed in the Services to Invoke Asynchronously list.
10. Select services that will be invoked asynchronously by selecting the check box next to the name of the service. Selecting a service causes it to be generated in the control's JCX file as an asynchronous service. This means it has a call-in with a void return and a callback with param as the service response type. Click OK.
11. In the Insert ApplicationView dialog, enter the WebLogic Workshop application name in the Application Name field. The application name is usually the same as that of the current WebLogic Workshop application.

The Application Name parameter allows you to reuse an application view between WebLogic Workshop applications. You must first define the application view in the context of the primary application (app1) using the Application Integration Design Console. Then, define an Application View control in a process or web service within a second application (app2) and specify app1 in the Application Name field in the Insert ApplicationView dialog. Because the browse function uses the context of the current application, you cannot use the browse function to locate application views in another WebLogic Workshop application. When reusing an application view from another application, all services are accessed synchronously.

12. Click Create.

### Application View Control Methods

To learn about the methods available on the Application View control, see the com.bea.wlai.control package in the WebLogic Integration Javadoc at the following URL:

http://edocs.bea.com/wli/docs81/javadoc/com/bea/wlai/control/package-summary.html

### Example: Application View Control

When you create a new Application File control, it appears in your project directory as a JCX file. The following is an example of an Application View control:

    package FunctionDemo;

    import weblogic.jws.*;
    import com.bea.wlai.control.ApplicationViewControl;
    import com.bea.xml.XmlObject;
    /**
     * This ApplicationView provides some simple services to
     * create/get/update customers in the sample CUSTOMER_TABLE table.
     * It also defines an event
     * indicating a customer record has been updated.
     * @jc:av-identity name="FunctionDemo.CustomerMgmt"
     * app="sampleApp"
     */
    public interface CustomerMgmtAppView extends
     com.bea.control.ControlExtension, ApplicationViewControl
    {

        /**
         * Get a customer record given first and last name.
         * @jc:av-service name="GetCustomer" async="false"
         */
    public wlai.functionDemo.
    customerMgmtGetCustomerResponse.RowsDocument
    GetCustomer(wlai.functionDemo.customerMgmtGetCustomerRequest.
    InputDocument request)
            throws Exception;

        /**
         * Update the customer's email address.
         * @jc:av-service name="UpdateCustomer" async="false"
         */

    public wlai.functionDemo.customerMgmtUpdateCustomerResponse.
    RowsAffectedDocument UpdateCustomer(wlai.functionDemo.
    customerMgmtUpdateCustomerRequest.InputDocument request)
            throws Exception;

        /**
         * Select all customers in the customer table.
         * @jc:av-service name="GetAllCustomers" async="true"
         */
        public void GetAllCustomers()
            throws Exception;

        /**
         * Create a new customer given first and last name,
         * and date of birth.
         * @jc:av-service name="CreateCustomer" async="false"
         */
    public wlai.functionDemo.
    customerMgmtCreateCustomerResponse.RowsAffectedDocument
    CreateCustomer(wlai.functionDemo.
    customerMgmtCreateCustomerRequest.InputDocument request)
            throws Exception;

        public interface Callback extends
     ApplicationViewControl.Callback

        {

            /**
             * Async response callback method for
             * GetAllCustomers service.
             */
    public void onGetAllCustomersResponse(wlai.functionDemo.
    customerMgmtGetAllCustomersResponse.RowsDocument response);

            /**
             * Callback to handle errors with async service requests.
             * Note that only one async request can be in flight
             * for a given control instance at any given time.
             *
             * @param errorMsg
             * The error message text for the failed async request.
             */
            public void onAsyncServiceError(String errorMsg);
        }
    }

If a business process or Web service does not implement the onAsyncServiceError callback, the Application View control does not write errors to the server log. WebLogic Workshop informs you when you build the application if the onAsyncServiceError callback is not implemented with warning messages similar to the following:

    WARNING: dummy.jpd:35: The Callback interface InsertAsyncCtrl.Callback
    defines a method void
    onInsertServiceResponse(wlai.dbms.masterApplicationViewInsertServiceResponse.
    RowsAffectedDocument), but you don't define an equivalent event handler.

    WARNING: dummy.jpd:35: The Callback interface InsertAsyncCtrl.Callback defines a
    method void onAsyncServiceError(java.lang.String), but you don't define an
    equivalent event handler.