CRecordWebAddStyleSheet
The message CRecordWebAddStyleSheet adds a stylesheet to the web page.
The message is part of the RemoteSkin Web API.
The API is located in the plugin NY_RemoteSkinWebProtocolAPI.
{
"id": "ae327d0d-989e-4431-a8ea-285d437c254f",
"name": "WEB_ADD_STYLE_SHEET",
"description": "Add a stylesheet.",
"slots": [
{
"key": "1",
"name": "ID",
"direction": "REQUEST",
"presenceConstraint": "MANDATORY",
"type": "STRING",
"description": "The style sheet ID."
},
{
"key": "2",
"name": "CONTENT",
"direction": "REQUEST",
"presenceConstraint": "MANDATORY",
"type": "STRING",
"description": "The content of the style sheet."
}
]
}
Arguments
- ID :The ID of the stylesheet. It is required to remove the stylesheet again later.
- CONTENT :The content of the stylesheet (the rules).
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.
// Example: Load style sheet from JAR resources
final String css = CUtilJson.loadJson(getClass(),
"/html/my_stylesheet.css");
mWebApi.addCss("id_of_my_stylesheet",
css);
Usage as message
The RemoteSkin target address is also required.
public void addCss(@NotNull final CTargetAddress aRemoteSkinAddress,
@NotNull final String aStyleSheetId,
@NotNull final String aCss) throws CException
{
// Envelope
final CEnvelope env = CEnvelope.forSingleTarget(mRemoteSkinAddress);
// Record
final CRecord record = CRecordWebAddStyleSheet.create();
CRecordWebAddStyleSheet.setId(record,
aStyleSheetId);
CRecordWebAddStyleSheet.setContent(record,
aCss);
// send message
sendNotification(env,
record);
}