setProperty

void setProperty(name: String, value: Object)

Description

Sets a property to the CDocBuilderValue object.

Please note, that for the .docbuilder file the CDocBuilderValue.setProperty method is not used.

Parameters

nameString
The name of the CDocBuilderValue object property.
valueObject
The value of the CDocBuilderValue object property.

Example

Java

CDocBuilder.initialize("");
CDocBuilder builder = new CDocBuilder();
CDocBuilderContext context = builder.getContext();
CDocBuilderValue global = context.getGlobal();
CDocBuilderValue api = global.get("Api");
CDocBuilderValue document = api.call("GetDocument");
document.setProperty("color", {"zX":{"red":112,"green":173,"blue":71,"alpha":255},"type":"srgb","Zvf":null,"type":"uniColor"});
CDocBuilder.dispose();

There are two more ways to set a property to the CDocBuilderValue object:

  1. use the set method that takes the object property name and value as arguments:

    void set(String name, Object value);
    

    Example

    Java

    CDocBuilder.initialize("");
    CDocBuilder builder = new CDocBuilder();
    CDocBuilderContext context = builder.getContext();
    CDocBuilderValue global = context.getGlobal();
    CDocBuilderValue api = global.get("Api");
    CDocBuilderValue document = api.call("GetDocument");
    document.set("color", {"zX":{"red":112,"green":173,"blue":71,"alpha":255},"type":"srgb","Zvf":null,"type":"uniColor"});
    CDocBuilder.dispose();
    
  2. use the default[] postfix expression:

    property CDocBuilderValue default[String]
    

    Example

    Java

    CDocBuilder.initialize("");
    CDocBuilder builder = new CDocBuilder();
    CDocBuilderContext context = builder.getContext();
    CDocBuilderValue global = context.getGlobal();
    CDocBuilderValue api = global.get("Api");
    CDocBuilderValue document = api.call("GetDocument");
    document["color", {"zX":{"red":112,"green":173,"blue":71,"alpha":255},"type":"srgb","Zvf":null,"type":"uniColor"}];
    CDocBuilder.dispose();
    

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).