0
votes

On an xpage in an edit box I would like to fire some ssjs (set scopevariable, call a function in a managed bean, perform a partial refresh) when the backspace key is used.

in csjs I could detect it:

 $('html').keyup(function(e){if(e.keyCode == 8)alert('backspace trapped')}) 

How do I do this is SSJS?

2
Do you need to pass any data when the backspace is pressed? - Rob Mason
That call will take some time. Users will notice freezes when backspacing. Several key strokes will cause partial refreshes with random delay and order. Don't do that. What exactly you want to do? - Frantisek Kossuth

2 Answers

0
votes

You need to use the CSJS code you have and kick off a partial refresh get / post via CSJS. To trigger a specific eventHandler, this code should work http://xpages.info/XPagesHome.nsf/Entry.xsp?documentId=88065536729EA065852578CB0066ADEC. SSJS will only run on the server, so there is no concept of user keystrokes there, only the post request data passed from the browser after a keystroke has occurred.

0
votes

it became something like this:

<xp:button value="Queue" id="btnQueue" styleClass="btn-primary">

    <xp:eventHandler event="onclick" submit="true" refreshMode="complete">
        <xp:this.action>

            <xp:actionGroup>
                <xp:executeScript>
                    <xp:this.script>
                        <![CDATA[#{javascript://my action(s) here}]]>
                    </xp:this.script>
                </xp:executeScript>

            </xp:actionGroup>
        </xp:this.action>

        <xp:this.script>
            <![CDATA[confirm("Are you sure you want to change from " + XSP.getElementById("#{id:inputFrom}").value +" to " + XSP.getElementById("#{id:inputTo}").value + "?")]]>
        </xp:this.script>
    </xp:eventHandler>
</xp:button>