Foren
Http session , PortletSession - value no saved
Petr Vašek, geändert vor 11 Jahren.
Http session , PortletSession - value no saved
Junior Member Beiträge: 68 Beitrittsdatum: 26.06.12 Neueste Beiträge
Hi all,
I have this problem. I overwrited login action class in file "LoginAction.java" by EXT plugin, where i used HttpSession and stored the simple string value.
and next , in LogoutPreAction.java i have this code
Why siteName is NULL ????
Please help me.
Petr
I have this problem. I overwrited login action class in file "LoginAction.java" by EXT plugin, where i used HttpSession and stored the simple string value.
HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
HttpSession session = request.getSession();
siteName = "TEST";
session.setAttribute("_currentSiteName", siteName);
//or i tried second way
actionRequest.getPortletSession().setAttribute("_currentSiteName", siteName, PortletSession.APPLICATION_SCOPE) ;
and next , in LogoutPreAction.java i have this code
HttpSession session = request.getSession();
String siteName = (String)session.getAttribute("_currentSiteName");
Why siteName is NULL ????
Please help me.
Petr
Petr Vašek, geändert vor 11 Jahren.
RE: Http session , PortletSession - value no saved
Junior Member Beiträge: 68 Beitrittsdatum: 26.06.12 Neueste Beiträge
I tried get session ID
Fist print in - LoginAction
Second - LogoutPreAction
Third - LogoutPostAction
why it's always diferent ID ? I dont understend it.
String sid = session.getId();
System.out.println("DEBUG : ACTUAL SESSION ID = " + sid);
Fist print in - LoginAction
Second - LogoutPreAction
Third - LogoutPostAction
why it's always diferent ID ? I dont understend it.
Petr Vašek, geändert vor 11 Jahren.
RE: Http session , PortletSession - value no saved
Junior Member Beiträge: 68 Beitrittsdatum: 26.06.12 Neueste Beiträge
I found problem
citation David H Nebinger:
One thing to beware of, though, is that unless they are part of the same WAR the portlet will not have access to the servlet session regardless.
So another way how share data between WARs by application session?
Thank you for any idea.
citation David H Nebinger:
One thing to beware of, though, is that unless they are part of the same WAR the portlet will not have access to the servlet session regardless.
So another way how share data between WARs by application session?
Thank you for any idea.
Petr Vašek, geändert vor 11 Jahren.
RE: Http session , PortletSession - value no saved
Junior Member Beiträge: 68 Beitrittsdatum: 26.06.12 Neueste Beiträge
I cant find solution. I am novice in java and Liferay too. So i see way in implement singelton "storage class", where i store data, but i dont know whether is good solution and
if it is good solution so in liferay doesnt exist any storage class?
Petr
if it is good solution so in liferay doesnt exist any storage class?
Petr
Petr Vašek, geändert vor 11 Jahren.
RE: Http session , PortletSession - value no saved
Junior Member Beiträge: 68 Beitrittsdatum: 26.06.12 Neueste Beiträge
Ok. My solution by Singelton storage class is function. Implementation of class is very simple:
if my solution is bad , so pleas post other solution.
I m repeating, i am novice in java and liferay
Thank you very much
import java.util.HashMap;
public class GlobalStorage {
private static GlobalStorage _instance;
private HashMap<string,object> _storage;
private GlobalStorage(){
_storage = new HashMap<string,object>();
}
public static GlobalStorage getInstance() {
if (_instance == null) {
_instance = new GlobalStorage();
}
return _instance;
}
public void setValue(String _key,Object _value) {
_storage.put(_key, _value);
}
public Object getValue(String _key) {
return _storage.get(_key);
}
public void removeValue(String _key) {
_storage.remove(_key);
}
public void clearStorage() {
_storage.clear();
}
}
</string,object></string,object>
if my solution is bad , so pleas post other solution.
I m repeating, i am novice in java and liferay
Thank you very much
Ay Kay, geändert vor 10 Jahren.
RE: Http session , PortletSession - value no saved
Junior Member Beiträge: 52 Beitrittsdatum: 17.11.11 Neueste Beiträge
No, not bad at all! In fact it solved the communication problem with my portlet and my hook - both residing in the same portlet project. Here's the thread.