Skip to Content
author's profile photo Former Member
Former Member

EP - problem when store data in session

Hi all,

I want to store data in session and it doesn't work:

status = INIT;

IPortalComponentRequest request =(IPortalComponentRequest) this.getRequest();

IPortalComponentSession session = request.getComponentSession();

session.putValue("status", status);

Any clues, I begin to lose patience.

regards

Nicolas

Add comment
10|10000 characters needed characters exceeded

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 22, 2004 at 02:42 PM

    Hi!

    What doesn't work? The objects in your session get lost if you try to get them

    via session.getValue("status")?

    What happens exactly?

    Greetings,

    Christian

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 22, 2004 at 02:42 PM

    Hi Nicolas,

    1.) you can surround code fragments with [ code ] and [/ code ] (without the spaces), so it will be much more readable.

    2.) What das not work?

    3.) Of what type is <i>status</i>? Primitive int? Then it cannot work, for a primitive isn't an object (another 100 years, and we will work an JDK 1.5 on EP, then this will work).

    4.) Do you need the status to be saved? Normally you won't.

    5.) If 3.) is the problem and the answer to 4.) ist Yes, just try

    session.putValue("status", new Integer(status));
    

    Hope it helps

    Detlev

    PS:

    6.) Please submit points for helpful answers just by pressing the yellow star button and choosing the corresponding amount of points. And be a bit more responsive than you have been till now when people try to help, this will raise the probability that people continue to help...

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      hi,

      There is another solution for store data in session. May be this code will be helpful

      package com.examples.session;
      
      
      import com.sapportals.htmlb.page.DynPage;
      import com.sapportals.htmlb.page.PageException;
      import com.sapportals.portal.htmlb.page.JSPDynPage;
      import com.sapportals.portal.htmlb.page.PageProcessorComponent;
      import com.sapportals.portal.prt.component.IPortalComponentRequest;
      import com.sapportals.portal.prt.component.IPortalComponentSession;
      
      public class SessionExample extends PageProcessorComponent {
      
        public DynPage getPage(){
          return new SessionExampleDynPage();
        }
      
        public static class SessionExampleDynPage extends JSPDynPage{
        
          public void doInitialization(){
      		IPortalComponentRequest req = (IPortalComponentRequest) getRequest();
      		IPortalComponentSession session = req.getComponentSession();
      		session.putValue("hello", "Hello World!!!"); 
          }
      
          public void doProcessAfterInput() throws PageException {
          }
      
          public void doProcessBeforeOutput() throws PageException {
            this.setJspName("FirstPage.jsp");
          }
        }
      }
      

      and Simple Jsp Page to get the stored data from the session

      <%@ page contentType="text/html; charset=UTF-8"%>
      <%@ taglib uri="tagLib" prefix="hbj" %>
      <hbj:content id="myContext" >
        <hbj:page title="SessionExample"> 
           <hbj:form id="MyForm1">
             <%=componentRequest.getComponentSession().getValue("hello")%>
           </hbj:form>
         </hbj:page>
      </hbj:content>
      

      Regards,

      Sai Krishna

  • author's profile photo Former Member
    Former Member
    Posted on Jul 15, 2005 at 06:41 AM

    Hi Nicolas,

    All of the above examples are good.

    For a more detailed explanation see:

    http://www.ajvic.net/irj/portalapps/com.sap.portal.pdk.htmlb.htmlbmanuals/docs/dynpage-01.html

    Good luck,

    Yoav.

    Add comment
    10|10000 characters needed characters exceeded