CRecordShowWebDialog

The CRecordShowWebDialog message can be used to create and display a dialog that has been deployed as a microservice.

The message is part of the Web Dialog API of RemoteSkin for Web. The API is part of the NY_RemoteSkinWebProtocolAPI plugin.

{
  "id": "d64362ee-b6cb-4dde-97e0-e51c7fbc2b03",
  "name": "SHOW_WEB_DIALOG",
  "description": "Create and show the web dialog.",
  "slots": [
    {
      "key": "1",
      "name": "CLIENT_TARGET_ADDRESS",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "TARGET_ADDRESS",
      "description": "The target address of the client."
    },
    {
      "key": "2",
      "name": "OWNER_TARGET_ADDRESS",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "TARGET_ADDRESS",
      "description": "The target address of the OWNER."
    },
    {
      "key": "3",
      "name": "PARENT_WIDGET_ID",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The ID of the HTML parent widget."
    },
    {
      "key": "4",
      "name": "PARAMS",
      "direction": "REQUEST",
      "mandatory": "FALSE",
      "type": "STRING_PROPERTIES",
      "description": "Optional: unspecified parameters."
    },
    {
      "key": "10",
      "name": "DIALOG_TARGET_ADDRESS",
      "direction": "ANSWER",
      "mandatory": "FALSE",
      "type": "TARGET_ADDRESS",
      "description": "The target address of the dialog."
    }
  ]
}

Usage

Show the dialog

To start a dialog that has been implemented as a microservice, we need

  • the microservice ID of the service
  • the target address of the WebSocketServer (client address). The dialog needs this to communicate directly with the DOM in the browser.
  • the ID of the html element in which the dialog should display its code (usually a div element)
  • the own target address This allows the dialog to communicate with the owner object and indicate that it has been closed, for example.
  • the session token
  • the dialog-specific parameters In the case of the dialog to change the password, we need the user ID.
// We want to show the dialog for changing the password
static final IId MICRO_SERVICE_ID = CIdFactory.fromObject("NY_WebDialogChangePassword_00309");
void showDialogChangePassword(final byte[] aSessionToken,
                              @NotNull final CTargetAddress aClientTargetAddress,
                              @NotNull final String aParentElementId,
                              @NotNull final String aUserId) throws CException
{
    // the envelope of the message
    final CEnvelope env = CEnvelope.forMicroService(MICRO_SERVICE_ID);
    env.setSessionToken(aSessionToken);
    
    // the record
    final CRecord record = CRecordShowWebDialog.create();
    CRecordShowWebDialog.setOwnerTargetAddress(record,
                                               getAddress());
    CRecordShowWebDialog.setClientTargetAddress(record,
                                                aClientTargetAddress);
    CRecordShowWebDialog.setParentWidgetId(record,
                                           aParentElementId);
    
    // these parameters are dialog-specific
    final CStringProperties params = new CStringProperties();
    params.put("userId",
               aUserId);
    CRecordShowWebDialog.setParams(record,
                                   aParams);
    
    // send the request
    sendRequest(env,
                record);
}

Usage of the RemoteSkin web dialog API class

It is easier to use the web dialog API class.

void showDialogChangePassword(final byte[] aSessionToken,
                              @NotNull final CTargetAddress aClientTargetAddress,
                              @NotNull final String aParentElementId,
                              @NotNull final String aUserId) throws CException
{
    final CWebDialogApi webDialogApi = new (this,
                                            aClientTargetAddress);
    final CStringProperties params = new CStringProperties();
    params.put("userId",
               mUserId);
    webDialogApi.showWebDialog(MICRO_SERVICE_CHANGE_PASSWORD,
                               aSessionToken,
                               aParentElementId,
                               params);
}