|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
|
|
|
Re: Setting attributes within ScriptSession + DefaultScriptSessionManager issueSince i am a newbie with DWR, I had to ask you this question. Based on your reply it seems I have to do something like this:
public class MyScriptSessionManager extends DefaultScriptSessionManager { public MyScriptSessionManager () { super.addScriptSessionListener(new MyScriptSessionListenerImpl()); } } public class MyScriptSessionListenerImpl implements implements ScriptSessionListener { public void sessionCreated(ScriptSessionEvent arg0) { } public void sessionDestroyed(ScriptSessionEvent arg0) { } } But doing so, I have one problem. I am going to add some user information, that is stored in HttpSession, e.g.(UserName) when user logs in, to ScriptSession upon its creation. But within MyScriptSessionListener, I will have access to ScriptSession but not HttpSession and I would not be able to extract information from HttpSession and set it to ScriptSession. Any thoughts on that? And BTW has the APIs changed due to which the old solution was not applicable.
|
|
|
Re: Setting attributes within ScriptSession + DefaultScriptSessionManager issueThe sessionCreated() and sessionDestroyed() destroyed events will be invoked every time a scriptSession is created and destroyed. This method will not be invoked in the ScriptSessionManager constructor. At this time you can call WebContextFactory.get().getHttpSession();
Cheers,
Lance.
2009/11/6 DNC1234 <devajyoti.c@...>
|
|
|
Re: Setting attributes within ScriptSession + DefaultScriptSessionManager issueThanks for the information. Based on your solution, its imperative that I have to move from DWR 2.0.5 to 3.rc1. Doing so, I ended up having another issue. Since my DWR reverse ajax happens outside DWR thread, I had to use Spring to inject ServletContext into the class for helping DWR get access to ServerContext, something like: -
public class MessageConsumer implements ServletContextAware { public void onMessage(..) { Collection sessions = ServerContextFactory.get(getServletContext()) .getScriptSessionsByPage("abcd.jsp"); ... } When I was using DWR 2.0.5 jar files this section of code worked correctly. But with the updated jar (3.rc1) I keep getting the following exception: ========================================================================== [2009-11-09 09:31:13,686] org.directwebremoting.impl.DefaultServerContextBuilder [FATAL] - Error initializing ServerContext because this is not a DWR thread and there is more than one DWR servlet in the current classloader. [2009-11-09 09:31:13,687] org.directwebremoting.impl.DefaultServerContextBuilder [FATAL] - This probably means that either DWR has not been properly initialized (in which case you should delay the current action until it has) [2009-11-09 09:31:13,687] org.directwebremoting.impl.DefaultServerContextBuilder [FATAL] - or that there is more than 1 DWR servlet is configured in this classloader, in which case you should provide a ServletContext to the get() yourself. =========================================================================== Also, the above piece of code is depicted as deprecated. If thats the case, what is the correct way to do this using DWR 3.x and what would be a solution to the exception thrown above. Regards, DNC
|
|
|
Re: Setting attributes within ScriptSession + DefaultScriptSessionManager issueI think I found the reason for the exception. It was thrown because, I had configured DWRSpringServlet in web.xml and had <dwr:controller id="dwrController" debug="true" > ... entry in spring configuration, which leads to duplication error. If you are using Spring use any one configuration set. This problem is specific to DWR 3 and did not happen with DWR 2.x. I found this out from one of the earlier posts.
Well, I am still try to find out about the deprecated APIs, and what I should use instead in DWR 3.x? Best Regards- DNC
|
|
|
Re: Setting attributes within ScriptSession + DefaultScriptSessionManager issue> Well, I am still try to find out about the deprecated APIs, and what I should use instead in DWR 3.x?
Not sure what you mean here... i've given you a place to intercept scriptSession creation and add attributes to it. What more do you need?
2009/11/9 DNC1234 <devajyoti.c@...>
|
| Free embeddable forum powered by Nabble | Forum Help |