on 07-04-2005 9:28 AM
Hi everyone,
Is it good to use an EJB statefull session to store a value for a specific session ?
Is it possible to use this EJB from a WebDynPro ?
Maybe using an EJB is to much heavy...is there another way ?
Hi David,
If state is related to business logic of your application and contains references to business objects it is better to have it in statefull session bean.
On other hand, if state is related to display logic and quite simple HTTP session is sufficient in most cases.
However, NW till NW04s does not expose any session related API as public. Also proposed here cookies-based approach has the same non-standard smell
I noticed someone on this forum try to use transient attributes of IUser object, probably you will evaluate this approach as well.
VS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks,
Now it compiles.
Here is what I did :
1) Create an application Sender and its component.
In the view, I created a button "Send". Here is the code in its action:
HttpServletRequest request = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();
request.setAttribute("key1", "val1");
2) Create an application Receiver and its component.
In the view, I created a button "Receive". Here is the code in its action:
HttpServletRequest request = ((IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();
String res = (String)request.getAttribute("key1");
wdComponentAPI.getMessageManager().reportSuccess(res);
In the Portal, I create 2 WebDynPro iViews : one for the send and one for the receiver.
I also created a Page that contains thoses 2 iViews.
When I click on the "Send" button and after on the "Receive" button, nothing appears.
Did I miss something ?
Thanks.
Your setting attributes in the request...
When you click Send you trigger a request in which you set attribute "key1".
When you click Receive you trigger ANOTHER request and since you probably don't go through the same Send action, the "key1" attribute is not set for the request.
Are both Web Dynpro views part of the same Web Dynpro application? If so, why not use the Component Controller Context to exchange data between two views?
Hi,
Where can i get the httpsession or HttpServletRequest in webdynpro,which jar have it?
Thanks,
Damodhar.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Right click on your Web Dynpro project (in package explorer), choose "Set Additional Libraries" from the context menu.
In the popup dialog, select Installed Libraries -> sap.com -> servlet.
This adds the jar containing httpservletrequest (and related classes) to the build classpath of your project.
public java.lang.String Put_Lang_in_Session(String value )
{
//@@begin Put_Lang_in_Session()
IMaintainScope maintainer = Utils.getScopeMaintainer( WDScopeType.CLIENTSESSION_SCOPE );
IScope scope = maintainer.getScope( );
String _key = new String( value );
scope.put( "Lang", _key);
// final IMaintainScope maintainer = Utils.getScopeMaintainer( WDScopeType.CLIENTSESSION_SCOPE );
// final IScope scope = maintainer.getScope( );
// scope.put( _key, _object);
return _key;
//@@end
}
public java.lang.String Get_Lang_from_Session( )
{
//@@begin Get_Lang_from_Session()
IMaintainScope maintainer = Utils.getScopeMaintainer( WDScopeType.CLIENTSESSION_SCOPE );
IScope scope = maintainer.getScope( );
String var_session = new String();
try{
var_session = scope.get("Lang").toString();
}
catch(Exception e){
var_session = e.toString();
}
return var_session;
//@@end
}
Hi David,
You could use the Cookies class but it would be a non standard API for WebDynpro.
Code would be something like
Cookie[] cookies = request.getCookies();
String cookieName = SAPCookie;
String defaultValue = 1;
for ( int i=0; i<cookies.length; i++) {
Cookie cookie = cookies<i>;
if (cookieName.equals(cookie.getName()))
return(cookie.getValue());
}
return(defaultValue);
}
Regards,
shyam.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello David,
you can use EJBs for storing a value for a session.
also u can use cookie to store values.
regards,
Piyush.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.