<sessionrpc>
SessionRPC object

JavaScript: lz.sessionrpc
extends <rpc> » <node> » lz.Eventable »

A class to get an http session object and invoke its methods. Remote method signatures are:

  • getAttribute(name): returns object, array, or primitive type.
  • getAttributeNames(): returns array of attribute names.
  • getId(): returns remote session id
  • getMaxInactiveInterval(): returns max inactive interval for session.
  • invalidate(): invalidate remote session.
  • isNew(): returns true if the client does not yet know about the session or if the client chooses not to join the session.
  • removeAttribute(name): remove attribute named name; returns void.
  • setAttribute(name,value): set attribute named name with value; returns void.
  • setMaxInactiveInterval(interval): set max inactive interval for session.

See javax.servlet.http.HttpSession in the Java Servlet API documentation for details.

<canvas height="475" debug="true">
    
        <debug x="300" y="20" width="500" height="400"/>
        
        <include href="rpc/sessionrpc.lzx"/>
        
        <dataset name="idDset"/>
        
        <sessionrpc id="session" autoload="false">
        
            <handler name="oninit">
                Debug.debug('loading session object...')
                this.load();
            </handler>
            
            <handler name="onload">
                Debug.debug('session object loaded');
                canvas.buttons.setAttribute('visible', true);
            </handler>        
            
            <handler name="ondata" args="data">
                Debug.debug("default ondata: %w", data);
            </handler>
            
            <handler name="onerror" args="error">
                Debug.debug("default onerror: %w", error);
            </handler>
            
            <remotecall funcname="getId"/>
            
            <remotecall name="getIdWithDset" funcname="getId" dataobject="idDset"/>
            
            <remotecall funcname="getMaxInactiveInterval"/>
            
            <remotecall funcname="isNew"/>
            
            <remotecall funcname="setMaxInactiveInterval">
                <param value="15"/>
            </remotecall>
            
            <remotecall name="setmyattr" funcname="setAttribute">
                <param value="'myattr'"/>
                <param value="'MY ATTRIBUTE'"/>
            </remotecall>
            
            <remotecall name="setmyother" funcname="setAttribute">
                <param value="'myother'"/>
                <param value="'MY OTHER'"/>
            </remotecall>
            
            <remotecall name="getmyattr" funcname="getAttribute">
                <param value="'myattr'"/>
            </remotecall>
            
            <remotecall name="getmyother" funcname="getAttribute">
                <param value="${'myother'}"/>
            </remotecall>
            
            <remotecall funcname="getAttributeNames"/>
            
            <remotecall name="removemyattr" funcname="removeAttribute">
                <param value="'myattr'"/>
            </remotecall>
            
            <remotecall name="removemyother" funcname="removeAttribute">
                <param value="'myother'"/>
            </remotecall>
        
        </sessionrpc>
        
        
        <view name="buttons" x="10" y="10" layout="spacing: 5" visible="false">
            <button text="getId" onclick="session.getId.invoke()"/>
            <button text="getIdWithDset" onclick="session.getIdWithDset.invoke()"/>
            <view height="20" width="50">
                <text datapath="idDset:/text()" width="240" bgcolor="red"/>
            </view>
            <button text="getMaxInactiveInterval" onclick="session.getMaxInactiveInterval.invoke()"/>
            <button text="isNew" onclick="session.isNew.invoke()"/>
            <button text="setMaxInactiveInterval" onclick="session.setMaxInactiveInterval.invoke()"/>
            
            <view x="20" layout="spacing: 5">
            
                <attribute name="myDel" value="null" type="expression"/>
                
                <handler name="oninit">
                this.myDel = new LzDelegate(this, 'myhandler');
                </handler>
                
                <method name="myhandler" args="data">
                    Debug.debug('myhandler: %w', data);
                </method>
                
                <button text="setmyattr" onclick="session.setmyattr.invoke()"/>
                
                <button text="setmyother" onclick="session.setmyother.invoke()"/>
                
                <button text="getmyattr" onclick="session.getmyattr.invoke()"/>
                
                <button text="getmyother" onclick="session.getmyother.invoke()"/>
                
                <button text="getmyattr (w/params)" onclick="session.getmyattr.invoke(['myattr'])"/>
                
                <button text="getmyattr (w/params and delegate)">
                <handler name="onclick">
                    session.getmyattr.invoke(['myattr'], parent.mydel);
                </handler>
                </button>
                
                <button text="getAttributeNames" onclick="session.getAttributeNames.invoke()"/>
                
                <button text="removemyattr" onclick="session.removemyattr.invoke()"/>
                
                <button text="removemyother" onclick="session.removemyother.invoke()"/>
                
            </view>
        </view>
    </canvas>
See Also:

Attributes inherited from <rpc>

autoload, proxy, proxyinfo, secure, secureport

Methods

load()
sessionrpc.load();
Loads session object.

Methods inherited from <rpc>

load, makeProxyStubFunction, unload

Methods inherited from lz.Eventable

destroy, setAttribute

Events

Events inherited from <rpc>

ondata, onerror, onload, onunload

Events inherited from <node>

onconstruct, ondata, oninit

Events inherited from lz.Eventable

ondestroy