CRecordWebAddClassesToElement

The message CRecordWebAddClassesToElement adds classes to an HTML element.
It is part of the RemoteSkin Web API.

{
  "id": "03e06095-b433-4411-b7e8-ee796265bd08",
  "name": "WEB_ADD_CLASSES_TO_ELEMENT",
  "description": "Add classes to an HTML element.",
  "slots": [
    {
      "key": "1",
      "name": "SELECTOR",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The selector."
    },
    {
      "key": "2",
      "name": "CLASS",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING",
      "description": "The class to add."
    },
    {
      "key": "3",
      "name": "CLASSES",
      "direction": "REQUEST",
      "mandatory": "true",
      "type": "STRING_ARRAY",
      "description": "The classes to add."
    }
  ]
}
    

Arguments

  • SELECTOR : A selector for identifying the HTML element, e.g. #id_my_element for an ID or .my_class for a class. Several elements can be changed at once.
  • CLASS : An HTML class to be added to the element. Use this slot if only one class is to be added.
  • CLASSES : An array of HTML classes to be added to the element.

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.addClassToElement("#id_my_element",
                          "class1");
    

or

mWebApi.addClassesToElement("#id_my_element",
                            Arrays.asList(new String[]{"class1","class2"}));
    

Usage as message

public void addClassesToElement(@NotNull final String aSelector,
                                @NotNull final String aClass) throws CException
{
    final CEnvelope env = CEnvelope.forSingleTarget(mRemoteSkinAddress);
    final CRecord record = CRecordWebAddClassesToElement.create();
    CRecordWebAddClassesToElement.setSelector(record,
                                              aSelector);
    CRecordWebAddClassesToElement.setClass(record,
                                           aClass);
    mTarget.sendNotification(env,
                             record);
}
    

nyssr.net - Innovative Distributed System