CRecordWebAddFirstChild: Insert a Child Element at the Beginning of an HTML Element

since version 2.5

The message CRecordWebAddFirstChild adds child elements at the beginning of an HTML element.

The message is part of the RemoteSkin Web API.
The API is located in the plugin NY_RemoteSkinWebProtocolAPI.

{
  "id": "c8123725-6e09-4a8b-a03f-71d5eb13effb",
"name": "WEB_ADD_FIRST_CHILD",
  "description": "Add an element as first child.",
  "slots": [
    {
      "key": "1",
      "name": "ID",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The id of the reference element."
    },
    {
      "key": "2",
      "name": "HTML",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The html of the element to insert."
    }
  ]
}

Arguments

  • ID : The ID of the HTML element to which a child element is to be added.
  • HTML : The HTML of the child element to be added.

Usage with the Helper Class CWebApi

The easiest way is to call the corresponding method in the CWebApi class. The use of the class is described there.

mWebApi.addFirstChild("id_of_my_list",
                      "<li>Banana</li>");

Usage as a Message

The RemoteSkin target address is also required.

public void addFirstChild(@NotNull final CTargetAddress aRemoteSkinAddress,
                          @NotNull final String aIdOfParentElement,
                          @NotNull final String aChildElement) throws CException
{
    // Envelope
    final CEnvelope env = CEnvelope.forSingleTarget(mRemoteSkinAddress);
    
    // Record
    final CRecord record = CRecordWebAddFirstChild.create();
    CRecordWebAddFirstChild.setId(record,
                                  aIdOfParentElement);
    CRecordWebAddFirstChild.setHtml(record,
                                  aChildElement);

    // send message
    sendNotification(env,
                     record);
}