Description

Web client and web site integration

General information

When you implement applications, you may need to integrate a web site with any specific application which is accessed through a web client. Such integration, for example, can provide for the opening of a web client inside <iframe> element of a web site HTML-page.

For the purpose of the said integration, the following has to be done:

  • Allocate an area on the web site page to run a web client.
  • Implement an interface (in 1C:Enterprise language) on the application side responsible for exchanging data with a web site being integrated with an application. Moreover, you need to select a proper mode for the application main window and enable users to operate in a proper client application main window mode by way of exercising their respective access rights.
  • Implement an interface (in JavaScript language) on the web site side being integrated with an application to enable a web client to get information as to the mode of operation and exchange of data with the said application.

This section describes all proper interfaces and lists an example of a simple web site and a configuration operating inside the said web site.

General integration requirements are as follows:

  • Make sure that an application is accessible through a web client (i.e. it is published on a web server).
  • Make sure that a web server is correctly set up so that integration of an application with a web site is supported.
  • To manage a web site with an integrated web client, use web browsers supported by 1C:Enterprise for web clients only.

Application Interface

Each application has ExternalSiteWindow global context property. Applications use this property to interface with web sites, when they are integrated therein. Such an interface allows it to perform the following:

  • Verify whether a web client operates as part of a specific web site, or not. This can be done by way of selecting ExternalSiteWindow.Accessible. Further, it is recommended to perform all actions with an external web site window manager (ExternalSiteWindow), only as soon as you make sure that this property is set to True.
  • Get messages from an external web site (vis-a-vis a web client) subject to prior registration of a handler method intended to handle messages received from a web site using ExternalSiteWindow.EnableMessageHandler(). Moreover, you can disable the processing of messages received from an external web site, if it is no more needed. For that purpose, select ExternalSiteWindow.DisableMessageHandler().
  • Send messages to an external web site using ExternalSiteWindow.SendMessage().

Only text data can be sent or received. Thus, to interact with an external web site, you need to develop your own exchange protocol and format.

The availability of selection of application main window mode is another distinctive feature of application setup process. It can be done as follows:

  • Using Main Client Application Window Mode.
  • Using a command-line intended to start a client application (MainWindowMode).
  • Using SetMainWindowMode().

Moreover, you need to ensure the availability of a proper client application main window mode by way of granting required access rights.

Web Site Interface

Do the following on the web site:

  • Specify an area where a web client interface will be displayed. For this purpose, use <div>. When loaded, a web client will by default add <iframe> subordinate element to the element so selected specifying all proper details.
  • Get the path to load web client JavaScript-interface code (Embedded WebClient API). As soon as this interface is loaded, WebClient1CE becomes available in the web browser. To load JavaScript-interface into the web site text, insert the following: <script src="%WebSiteURL%/%InfobaseName%/scripts/webclient1ce.js"></script>.
  • Implement 1C:Enterprise API.

Let's take a closer look at WebClient1CE:

  • Wizard WebClient1CE(webClientContainerID, config), where:
    • webClientContainerID ‑ of String kind ‑ is <div> element ID, where <iframe> is embedded to run a web client. Mandatory parameter.
    • config ‑ of Object kind ‑ is an object which specifies web client settings. Mandatory parameter.
  • gotoURL(navigationURL) ‑ enables you to follow the URL so specified. It operates similarly to FollowURL() 1C:Enterprise language method. Method parameters:
    • navigationURL ‑ of String kind ‑ is URL which is followed. This is a mandatory parameter.
  • postMessage(message) ‑ sends text specified as a parameter to a web client. Whenever this method is used in an application, handlers are called which are enabled through ExternalSiteWindow.EnableMessageHandler(). Method parameters:
    • message ‑ of String kind ‑ defines text which is sent to a web client. Mandatory parameter.

A setting object which is sent as a parameter to WebClient1CE object wizard has the following properties:

  • webClientURL ‑ of String kind ‑ is a line intended to start a web client (including command-line commands and parameters used to start a web client). This is a mandatory parameter.
  • width ‑ of String kind ‑ defines the width of an embodiment area (<iframe>) specifying a unit of measure. This is an optional parameter.
  • height ‑ of String kind  ‑ defines the height of an embodiment area (<iframe>) specifying a unit of measure. This is an optional parameter.
  • events ‑ of Object kind ‑ is an object which describes event handlers received from the embedded web client. This is an optional parameter.

An object which describes event handlers received from a web client has the following properties:

  • onStart ‑ of Function kind ‑ is a function (no parameters) called as soon as an application is started. It is called, as soon as operation of OnStartSystemOperation event handler is terminated in the embedded application. This is an optional parameter.
  • onEnd ‑  of Function kind ‑ is a function (no parameters) called before operation an application is terminated. It is called, as soon as the operation of OnEndSystemOperation event handler is terminated in the embedded application. This is an optional parameter.
  • onMessage ‑ of Function kind ‑ is a function that is called to get a message from an application. To send a message, select ExternalSiteWindow.SendMessage(). onMessage has the following parameters:
    • message ‑ of String kind ‑ defines text of a message sent by an application.
    • origin ‑ of String kind ‑ refers to a web client's primary address. The string includes protocol, domain, and port.

      This is an optional parameter.

  • onFormOpen ‑ of Function kind ‑ is a function that is called as soon as the application form is opened ( onOpening event handler operation is terminated). onFormOpen has the following parameters:
    • url ‑ of String kind ‑ is URL of a form being opened. This string is empty if a form being opened has no URL.
    • formName ‑ of String kind ‑ defines the name of a form being opened which is generated based on the English version of 1C:Enterprise language.

      This is an optional parameter.

  • onFormClose ‑ of Function kind ‑ is a function that is called as soon as the application form is closed (onClosing event handler operation is terminated). onFormClose has the following parameters:
    • url ‑ of String kind ‑ is URL of a form being opened. This string is empty, if a form being opened has no URL.
    • formName ‑ of String kind ‑ defines the name of a form being opened which is generated based on the English version of 1C:Enterprise language.

      This is an optional parameter.

Be the first to know tips & trick on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.