sessionScope variables are null

104 Views Asked by At

I am trying to get handle on sessionScope variables but thay are not being recognized immediately on the next page. Sorry for lots of info here but any ideas?

First XCpage has a customControl named ccMultipleLoadHandlers. In the custom control there is a repeat control which gets a handle on data in a Domino view and the last column is a link which sets several sessionScope variables and opens another XPage. Here is the code for the link.

                                        <xp:link
                                            escape="true"
                                            id="link3"
                                            text="${langBean.labelEdit}"
                                            value="/RemanRental.xsp">
                                            <xp:this.onclick><![CDATA[#{javascript:sessionScope.calitm=""}]]></xp:this.onclick>
                                            <xp:eventHandler
                                                event="onclick"
                                                submit="true"
                                                refreshMode="norefresh">
                                                <xp:this.action><![CDATA[#{javascript:importPackage(com.mycorpname);
dBar.info("Entering Link for ccRentMultLoadHandView")
try{
    var doc
    var calitm
    var caitm
    sessionScope.rentDisplay = "MultLoadHandDisplay";
    var hostURL = configBean.getValue("HostURL")
    var hostName = configBean.getValue("HostCommon")
    var dbName = configBean.getValue("rentalDbPath")
    var webPath = configBean.getValue("WebsiteURL")
    try{
        //var rtn
        var urlPath = hostURL+webPath
        dBar.info("urlPath:  "+urlPath)
        if(rowData.isDocument()){
            dBar.error("rowData is Document");
            doc = rowData.getDocument();
            if (doc != null){
                calitm = doc.getItemValue("CALITM");
                modelNbr = calitm[0];
                dBar.error("1. modelNbr="+modelNbr);
                modelNbr =modelNbr.slice(2);
                dBar.error("2. modelNbr="+modelNbr);
                sessionScope.calitm = modelNbr;
                dBar.error("CALITM IS "+sessionScope.calitm)
                caitm = doc.getItemValue("CAITM");
                sessionScope.caitm = caitm[0];
                dBar.error("ccRentMultLoadHandView >>>> CAITM IS "+sessionScope.caitm)
                var fam = doc.getItemValue("family");
                sessionScope.family=fam[0];
                var strURL = urlPath+"/Rental.xsp?"
                dBar.info("Returning:  "+urlPath+"/Rental.xsp?databaseName="+hostName+"!!"+dbName+"&documentId="+rowData.getUniversalID()+"&action=openDocument");
                sessionScope.urlPath = urlPath+"/RemanRental.xsp?databaseName="+hostName+"!!"+dbName+"&documentId="+rowData.getUniversalID()+"&action=openDocument"
                return urlPath+"/Rental.xsp?databaseName="+hostName+"!!"+dbName+"&documentId="+rowData.getUniversalID()+"&action=openDocument"
        } else {
                dBar.info("Unable to get handle on document");
            }
        }
    } catch (e) {
        dBar.info("1. ccRentMultLoadHandView >> link error >>>Unable to get handle on document.  " + e.toString());
        println("1. ccRentMultLoadHandView >> link error>>>>  " + e.toString());
        return e.toString()
    }

} catch (e) {
    dBar.info("2. ccRentMultLoadHandView >> link try error >> Unable to get handle on document.  " + e.toString());
        println("2. ccRentMultLoadHandView >> link try error>>>>  " + e.toString());
    return e.toString()
}}]]></xp:this.action>
                                            </xp:eventHandler>
                                        </xp:link>

The opened XPage has a custom control named ccRentMultLoadHandleDisplay which has code in the afterPageLoad event. That code is:

importPackage(com.mycorpname);
dBar.error(">>>> sessionScope.rentDisplay is "+sessionScope.rentDisplay+" <<<<")
if (sessionScope.rentDisplay=="MultLoadHandDisplay"){
try{

// ***** Get RENTAL Specs ****      
            var table = configBean.JdbcTable_03;
            sessionScope.jdbcTable = table;
            dBar.error("ccRentMultLoadHandDisplay>>>sessionScope.rentDisplay = "+sessionScope.rentDisplay);
            var caitm = sessionScope.caitm;
            dBar.info("ccCartonlampDisplay>>var caitm is:  "+caitm);
            var calitm = sessionScope.calitm;
            dBar.info("ccCartonlampDisplay>>var calitm is:  "+calitm);
            getComponent("modelNbr").setValue(calitm);
            dBar.warn("rentBean.getMultLoadHandData("+caitm+","+sessionScope.Region+","+ table+","+ sessionScope.family+")")
            var returnMap=new com.ibm.jscript.std.ObjectObject();
            returnMap = rentBean.getMultLoadHandData(caitm,sessionScope.Region, table, sessionScope.family);
            dBar.info( "Got Rental Specs");
            
            var i;
            var rmc //return map component
            var value
            //dBar.info("return map size: " + returnArray.size());
            sessionScope.returnArray=true
            //dBar.info("returnArray.getCACLLB()= "+returnArray.getCACLLB());
        
            // we will now set the values not set above.  what they gets set to depends on values set in othe fields above
            dBar.error("ccRentMultLoadHandDisplay>>>Entering CartonClampDisplay data");
            for ( i in returnMap ){
                dBar.warn("ccRentMultLoadHandDisplay>>>i = "+i.toUpperCase());
                rmc = i.toUpperCase();
                var value = returnMap[i];
                value = Number(returnMap[i])/100;
                //dBar.warn("RemanRental>>>value = "+value);
                var fieldVal;
                switch(rmc.trim()){
                    case "CAACMT":
                        fieldVal = String(returnMap[i]);
                        dBar.warn("ccRentMultLoadHandDisplay>>>String(value) CAACMT = "+fieldVal);  
                        getComponent(rmc.trim()).setValue(fieldVal);
                        break;
                    case "CAMFCL":
                        fieldVal = String(returnMap[i]);
                        dBar.warn("ccRentMultLoadHandDisplay>>>String(value) CAMFCL = "+fieldVal);  
                        getComponent(rmc.trim()).setValue(fieldVal);
                        dBar.warn(rmc.trim()+":  "+getComponent(rmc.trim()).getValue());
                        break;
                    default:
                        dBar.warn("ccRentMultLoadHandDisplay>>>value = "+value);
                        getComponent(rmc.trim()).setValue(value);
                        dBar.warn(rmc.trim()+":  "+getComponent(rmc.trim()).getValue());
                        break;
                }
                }
} catch(e){
    println("There was an error in ccRentCartonDisplay afterPageLoaad");
    dBar.error("ccRentMultLoadHandDisplay---->Error in afterPageLoad:  "+ e.toString());
    println("ccRentMultLoadHandDisplay-----> Error in afterPageLoad: "+ e.toString());
}
}

The problem is that the sessionsScope variables are null but if I reload the page they are there and code properly sets fields

Here are messages that are displayed in the Debug Tool Bar

XXXXXX

09:29:40 3. sizeGen=

09:29:40 3. funct=

09:29:40 2. modelNbr=

09:29:40 1. modelNbr=

09:29:40 ENTERING IMAGE TRY CODE

09:29:40 RemanRental>>>Entering afterPageLoad

09:29:40 >>>> sessionScope.rentDisplay is null <<<<

09:29:40 >>>> before page load: sessionScope.rentDisplay is null <<<<

XXXXXXX

And here are the recorded sessionScoped variables:

XXXXXXXX caitm: 2362656

calitm: 25G-FDS-1200

rentDisplay: MultLoadHandDisplay

rentView: Multiple Load Handlers

XXXXXXXX

The resulted page is: enter image description here If I reload the pae second page, then the sessionScope variables are recognized Resulted page is: enter image description here

1

There are 1 best solutions below

0
Mike Zens On

I created a custom control named reoladPage, then added client side set timeout script block per Knut Herrmann suggestion in this posting: Need to reload an XPage after a few seconds. I added the custom control to my XPage. Problem solved.