Search code examples
xpageslotus-domino

how to disable xPage placeBar button?


I have placebar button defined like this:

<xc:ccMain>
    <xc:this.placeBarActions>
        <xe:basicLeafNode label="Save" onClick="XSP.executeOnServer('#{id:saveEventHandler}','#{id:applicationLayout1}')">
        </xe:basicLeafNode>
        ..........

and then:

    <xp:eventHandler id="saveEventHandler" submit="true" event="calledbyid" refreshMode="complete" action="#{javascript:saveDocument();}"></xp:eventHandler>

I want to disable that "Save" button onClick event especially by Client Side JS

Thank you


Solution

  • You want to disable button "Save" during document's saving and page reloading.

    Your basicLeafNode is a child of placeBarActions.
    It gets rendered to

    <span class="lotusBtn">
        <a href="javascript:;" onclick="javascript:...">Save</a>
    </span>
    

    Unfortunately, there is no property "disabled" for a href tag for easy button disabling.

    Overwrite button's onclick event with 'return false;' instead. It does nothing when user clicks button a second time during execution.

    Set color to gray to make it visible that button is disabled during execution. You have to set it with color:gray !important because OneUI's definition for .lotusBtn a is color: #000 !important which would overrule the gray setting otherwise.

    Change your code this way

    <xe:basicLeafNode
        label="Save"
        onClick="event.target.onclick= 'return false;';
                 event.target.setAttribute('style', 'color:gray !important');
                 XSP.executeOnServer('#{id:saveEventHandler}', '#{id:applicationLayout1}');">
    </xe:basicLeafNode>
    

    As this basicLeafNode is part of applicationLayout1 it gets restored to it's original content after page is reloaded.