|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Reverse Ajax not wrking plz helpjava 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 |
|
|
Re: Re[dwr-user] verse Ajax not wrking plz helpWebContextFactory.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@...>
|
|
|
Re: Re[dwr-user] verse Ajax not wrking plz helpI tend to use the alternatative method listed here to access servlet objects
It makes the code easier to test and easier to integrate with code not invoked by DWR threads.
2009/6/12 Lance Java <lance.java@...> 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. |
|
|
Re: Re[dwr-user] verse Ajax not wrking plz help@ Lance thnx for help
i tried but it didnt wrk out ... can u suggest smthing else ..... i m confused abt javascript .....is it fine ?? thnx .... |
|
|
Re: Re: Re[dwr-user] verse Ajax not wrking plz helpThe JS looks ok to me does your "hello" debug work? If not, try running from the dwr debug page http://hobione.wordpress.com/2007/12/14/debug-dwr/
Try logging the size of the scriptSession collection in getit() is it 0? Have you installed the Firebug plugin in Firefox? It's an invaluable tool for debugging javascript and the "net" tab is handy for seeing ajax requests / responses.
2009/6/12 aakar <aakar.gupta@...>
|
| Free embeddable forum powered by Nabble | Forum Help |