Search code examples
xpages

xpages button - possible to change text or item while events are running?


Is it possible to change the text on an <xp:button> element when the code under the onclick event is running (and the partial refresh is not completed)?


Solution

  • The XPages way is to use the onStart and onComplete properties (there's also onError):

    <xp:button value="Search" id="button1">
        <xp:eventHandler event="onclick" submit="true" refreshMode="partial" 
            onStart="changeText()" onComplete="unchangeText()">
                <xp:this.action><![CDATA[#{javascript:serverFunction();}]]></xp:this.action>
        </xp:eventHandler>
    </xp:button>
    

    You can pass the id of the button to the functions using "#{id:button1}" and use it to retrieve the button in CSJS.