Roman
Roman

Reputation: 127

XPages theme and dojo attributes

How i can set dojo attributes and dom attributes via Theme in XPages?

It's posible?

I want set dojo skin for all CKEditor, for example i set dojoType..

<control>
    <name>InputField.RichText</name>
    <property>
        <name>dojoType</name>
        <value>MY_DOJO_TYPE</value>
    </property>
</control>

UPD: I try this code, but it does not work

<property>
    <name>dojoAttributes</name>
    <complex type="xp_dojoAttribute">
        <property>
            <name>name</name>
            <value>skin</value>
        </property>
        <property>
            <name>value</name>
            <value>MY_CKEDITOR_SKIN_PATH</value>
        </property>
    </complex>
</property>

Upvotes: 0

Views: 269

Answers (1)

Lothar Mueller
Lothar Mueller

Reputation: 2528

Tony McGuckin added a code snippet on openntf.org a while ago which seems to be doing what you are loking for:

https://openntf.org/XSnippets.nsf/snippet.xsp?id=set-dojoattributes-and-attrs-on-a-control-in-an-xpages-theme-file

Haven't tried myself so far but think it's a good idea to do it that way!

Edit: just tried a few options myself; got some things to work, others wouldn't react at all or even throw runtime errors. Here's a list of what is working and what not:

I defined a custom theme id for the control ccDocRtf.inputRichtext1.

dojoType: this is a computed property at the control level; within the theme I put it like that:

<control>
    <name>ccDocRtf.inputRichtext1</name>
    <property mode="override">
        <name>dojoType</name>
        <value>#{javascript:@ClientType().equals("Web") ? "my.custom.packagename.CKEDITOR" : ""}</value>
    </property>

dojoAttributes: all static attribute settings are working fine, e.g.:

    <property
        mode="override">
        <name>dojoAttributes</name>
        <complex
            type="xp_dojoAttribute">
            <property>
                <name>name</name>
                <value>toolbar</value>
            </property>
            <property>
                <name>value</name>
                <value>myToolbarName</value>
            </property>
        </complex>
        <complex
            type="xp_dojoAttribute">
            <property>
                <name>name</name>
                <value>extraPlugins</value>
            </property>
            <property>
                <name>value</name>
                <value>autogrow</value>
            </property>
        </complex>
        <complex
            type="xp_dojoAttribute">
            <property>
                <name>name</name>
                <value>width</value>
            </property>
            <property>
                <name>value</name>
                <value>99%</value>
            </property>
        </complex>
    </property>
</control>

I have two more attributes to set that need to be computed; for some reason I couldn't get those to work. Maybe I'll find the time to investigate a bit further as I find this an interesting option.

Upvotes: 1

Related Questions