EGL Development User Group

EGL Development User Group

EGL Development User Group

The EGL Development User Group is dedicated to sharing news, knowledge, and insights regarding the EGL language and Business Developer product. Consisting of IBMers, HCL, and users, this community collaborates to advance the EGL ecosystem.

 View Only
Expand all | Collapse all

Maintaining a session between JSF and RUI

  • 1.  Maintaining a session between JSF and RUI

    Posted Mon July 13, 2015 11:35 AM

    Hello. While I have experience as a programmer, I'm new to EGL specifically. The company I work for wants to port their website from Java Server Pages to Rich UI. However, because the program still works and can't stop providing a product to remake everything, what we would like to do is have the two co-exist. New development would be in Rich UI, but the existing framework would remain and be migrated over to Rich UI as time permits. The current application makes frequent use of J2eeLib and session attributes. In my testing, the existing work environment is a web project, and I've created a Rich UI project that deploys to the web project. In my web project, I've created a service that the Rich UI can call to get and set session attributes.

     

    The main issue I am having is that, while the session attribute works within the JSF page, and works within the RUI page, it is not maintained between the two. 

    In the JSF page I have this line:

    J2eeLib.setSessionAttr("keyname", "test");

    In the service ( A stateful REST service) I have this:

    service sessiontestservice
        function retrieveSessionVar(key string in) returns (string)
            SysLib.writeStdout("Entering the retrieveSessionVar function.");
            returnVal string = J2EELib.getSessionAttr("EGL.welcomeheader");
            SysLib.writeStdout("printing returnval" +returnVal);
            return(returnVal);
        end
        
        function setSessionAttr(key string in, value string in)
            J2EELib.setSessionAttr(key, value);
        end

    end

     

    In the RUI page I have:

        sessionService sessiontestservice{@dedicatedService};

       function Button_onClick(event Event in)
           sessionVal string;
            call sessionService.retrieveSessionVar("keyname")
                returning to displaySessionVar
                onException handleException
                {timeout = 1000};
       end

     

        function displaySessionVar(sessionVar string in)
            if (sessionVar != null)
                SessionVarTextLabel.text = sessionVar;
            else
                SessionVarTextLabel.text = "Could not read session variable.";
            end
        end

     

    If I set a dummy session attribute within the sessiontestservice, I can retrieve it. If I set the session attribute from within the JSF page, it will not remember the attribute if I try to retrieve it from within the Rich UI page. I've looked at the following topics: topic 1topic 2, and it seems like this approach will work, but I wasn't able to open the attached sample. If this approach is not workable, I would appreciate advice on what the best way to remember a user is, that would require the least amount of code conversion. Thank you in advance, and let me know if you need additional information.

    Warner33


  • 2.  Re: Maintaining a session between JSF and RUI

    Posted Mon July 13, 2015 10:28 PM

    Hi Warner33,

    If the users want to share sessions, the RUI and JSF should be in the same project(war). That is, deploy RUI project into the JSF web project. I try with your code, it works with one change:

    returnVal string = J2EELib.getSessionAttr("EGL.welcomeheader"); ->returnVal string = J2EELib.getSessionAttr(key);  //This is in service sessiontestservice,   function retrieveSessionVar

    -Jiyong

     

    HuangJiYong