« Return to Thread: Reverse Ajax not wrking plz help

Re: Re[dwr-user] verse Ajax not wrking plz help

by Lance Java :: Rate this Message:

Reply to Author | View in Thread

WebContextFactory.get() only works for threads that are initiated by a DWR request. I'm not sure of the scope of Mani but I'm guessing that the constructor is not invoked by a DWR request. If you move the WebContextFactory.get() call inside getit() it will hopefully work.

Cheers,
Lance.

2009/6/12 aakar <aakar.gupta@...>

java file

package mani;
import java.util.Collection;


import javax.servlet.ServletContext;

import org.directwebremoting.ServerContext;
import org.directwebremoting.ServerContextFactory;
import org.directwebremoting.WebContextFactory;
import org.directwebremoting.proxy.dwr.Util;


public class Mani
{
private ServerContext sctx=null;

public Mani()
{
       ServletContext servletContext =
WebContextFactory.get().getServletContext();
   sctx = ServerContextFactory.get(servletContext);

}
       public synchronized void getit() throws InterruptedException
       {
       Collection sessions = sctx.getScriptSessionsByPage("/Aakar/index.html");
       Util pages = new Util(sessions);
       System.out.println("Hello");
       pages.setValue("one","Calling");
       Thread.sleep(5000);
       pages.setValue("one","Established");

       }


}



web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="Aakar" version="2.5">


 <servlet>
 <servlet-name>dwr-invoker</servlet-name>
 <!-- <display-name>DWR Servlet</display-name> -->
 <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
 <init-param>
   <param-name>debug</param-name>
   <param-value>true</param-value>
 </init-param>
 <init-param>
     <param-name>activeReverseAjaxEnabled</param-name>
     <param-value>true</param-value>
   </init-param>
   <init-param>
     <param-name>initApplicationScopeCreatorsAtStartup</param-name>
     <param-value>true</param-value>
   </init-param>
   <init-param>
     <param-name>maxWaitAfterWrite</param-name>
     <param-value>500</param-value>
   </init-param>
       <load-on-startup>1</load-on-startup>
 </servlet>
 <servlet-mapping>
 <servlet-name>dwr-invoker</servlet-name>
 <url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
</web-app>



dwr.xml


<!DOCTYPE dwr PUBLIC
   "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN"
   "http://getahead.org/dwr/dwr20.dtd">

<dwr>
 <allow>
   <create creator="new" javascript="Mani" scope="application" >

   </create>
 </allow>
</dwr>


index.html file

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Aakar</title>
<script type='text/javascript' src='../dwr/interface/Mani.js'></script>
<script type='text/javascript' src='../dwr/engine.js'></script>
<script type='text/javascript' src='../dwr/util.js'></script>
<script type="text/javascript">
</script>
</head>
<body onload="dwr.engine.setActiveReverseAjax(true);">
<br/>
<div id="one">
</div>
<br/>
<input type="button" value="Yo Man" onclick="Mani.getit();" />
<script type="text/javascript">
</script>
</body>
</html>


the above code is not wrking out ....plz help me .........
Thanx in advance
--
View this message in context: http://www.nabble.com/Reverse-Ajax-not-wrking-plz-help-tp23996376p23996376.html
Sent from the DWR - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


 « Return to Thread: Reverse Ajax not wrking plz help