on 12-22-2004 2:32 PM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem is: I store data in session(a string).Then I want to use it in a jsp. The code I write is the code in doInitialization() method.
The fact is when I try to use this string(<jsp:usebean id="status" scope="session" class="java.lang.String"/>), it's empty(length=0).
The final goal is to open a window when you click on a button and in this window, a .doc will be generate by the onClickButton() method.
Hi Nicolas,
just try the following minimized example. This has to work. If it does not, there'll be a problem within your portal version.
JSPDynPage:
package com.btexx;
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 ExampleJSPDynPage
extends PageProcessorComponent {
public DynPage getPage() {
return new RealJSPDynPage();
}
public static class RealJSPDynPage extends JSPDynPage {
public RealJSPDynPage() {
}
public void doInitialization() {
IPortalComponentRequest req = (IPortalComponentRequest) getRequest();
IPortalComponentSession session = req.getComponentSession();
session.putValue("test", "hallo");
}
public void doProcessAfterInput() throws PageException {
}
public void doProcessBeforeOutput() throws PageException {
setJspName("example.jsp");
}
}
}
JSP:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="tagLib" prefix="hbj" %>
<jsp:useBean id="test" scope="session" type="java.lang.String" />
<hbj:content id="myContext" >
<hbj:page title="myTitle">
<hbj:form id="ContactPersonsAdminForm">
<%=test%>
</hbj:form>
</hbj:page>
</hbj:content>
Hope it helps
Detlev
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.