Question

I have this deep desire to use the xe:toolbar control for saving documents, but I can't figure out how to do this. I have this code and have found that navigating is easy. But saving...

<xe:toolbar
    id="toolbar2">
    <xe:this.treeNodes>
        <xe:basicLeafNode
            href="whereToGo.xsp"
            label="Save and close">
            <xe:this.onClick>
                <![CDATA["<WHAT GOES HERE?>"]]>
            </xe:this.onClick>
        </xe:basicLeafNode>
    </xe:this.treeNodes>
</xe:toolbar>
Was it helpful?

Solution

The onClick event of the basicLeafNode is for client-side JS only. You need to use the submitValue property of each basicLeafNode to and then add SSJS to the onItemClick event of the outline control. You can then use context.getSubmittedValue() to check what node was clicked and then act accordingly.

See my answer here: https://stackoverflow.com/a/14760609/785061

OTHER TIPS

The Problem is that you only have the clientSide onClick. You can call a SSJS EventHanlder from the ClientSide like discripted by Jeremy Hodge.

For this example i used the full executeOnServer script from Jeremy but i think you could alter it a bit. I also used a full refresh you could also use a partial refresh if you dont want to refresh the complete page.

    <xe:toolbar
        id="toolbar2">
        <xe:this.treeNodes>
            <xe:basicLeafNode
                href="whereToGo.xsp"
                label="Save and close"
                onClick="executeOnServer('saveDocument');">
            </xe:basicLeafNode>
        </xe:this.treeNodes>
    </xe:toolbar>

    <xp:scriptBlock>
        <xp:this.value><![CDATA[

    var executeOnServer = function () {
        if (!arguments[0])
            return false;

        var functionName = arguments[0];
        var refreshId = (arguments[1]) ? arguments[1] : "@none";
        var form = (arguments[1]) ? XSP.findForm(arguments[1]) : dojo.query('form')[0];
        var options = (arguments[2]) ? arguments[2] : {};
        dojo.query('[name="$$xspsubmitid"]')[0].value = form.id + ':' + functionName;
        XSP._partialRefresh("post", form, refreshId, options);

    }
]]></xp:this.value>
    </xp:scriptBlock>

    <xp:eventHandler event="saveDocument" submit="false"
        id="saveDocument">
        <xp:this.action>
        <xp:actionGroup>
            <xp:executeScript>
                <xp:this.script><![CDATA[#{javascript:println("save")}]]></xp:this.script>
            </xp:executeScript>
            <xp:save></xp:save>
        </xp:actionGroup>
    </xp:this.action>
    </xp:eventHandler>

Another way would be (as Oliver already mentioned) to use a real button placed in an hidden div.

Here is what I ended up doing. Per's suggestion led to to investigate the onItemClick event for the toolbar, and it turned out to be quite easy. Thanks to all for contributions!

<xp:this.data>
    <xp:dominoDocument
        var="docPrognosis"
        formName="prognosis"
        computeWithForm="onsave">
    </xp:dominoDocument>
</xp:this.data>
<xe:toolbar
    id="toolbar1">
    <xe:this.treeNodes>
        <xe:basicLeafNode
            label="Save"
            submitValue="save">
        </xe:basicLeafNode>
    </xe:this.treeNodes>
    <xp:eventHandler
        event="onItemClick"
        submit="true"
        refreshMode="complete">
        <xe:this.action>
            <![CDATA[#{javascript:
            if (context.getSubmittedValue() == "save") {
                if (docPrognosis.save()) {
                    context.redirectToPage("prognosisview.xsp");
                }
            }
        }]]></xe:this.action>
    </xp:eventHandler>
</xe:toolbar>

If you want to use the simple actions (Save document) then: set up the toolbar and save node with a submit value = 'save', then in simple actins add an action group with the condition formula: context.getSubmittedValue() == "save". Now add simple actions for this action.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top