dwr

Getting json by DWR (Direct Web Remoting)

不羁岁月 提交于 2020-01-16 20:10:13
问题 I want to know how can I convert a Java object to JSON by using DWR. I have already tried JsonUtil.toJson(myObject) , but it gives a NullPointerException at org.directwebremoting.json.JsonUtil.toJson(JsonUtil.java:127) . Can anyone tell me any way of converting the Java Object to JSON? I would prefer achieving it by DWR. 回答1: Why not use the JSON library itself? JSON Or even the Google-Gson Library GSON Also, for further reference, use the Search, since similar questions to this one have been

no issue is shown but does not work - dwr

左心房为你撑大大i 提交于 2020-01-06 04:19:06
问题 Hi all i am using dwr to handle ajax calls in java-servlet, this is what is my dwr.xml, <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE dwr PUBLIC "-//GetAhead Limited//DTD Direct Web Remoting 2.0//EN" "http://getahead.org/dwr/dwr20.dtd"> <dwr> <allow> <create creator="new" javascript="TempCardServlet"> <param name="class" value="com.slingmeadia.notifier.servlet.TempCardServlet"/> </create> </allow> </dwr> and this what is my servlet file and in that i call the package com.slingmeadia

Is there a JavaScript API for XML binding - analog to JAXB for Java?

倖福魔咒の 提交于 2019-12-30 00:54:08
问题 In Java, we work a lot with JAXB2. Object<->XML mappings are defined as annotations in Java classes: @XmlRootElement(name="usertask", namespace="urn:test") public class UserTask { @XmlElement(namespace="urn:test") public String getAssignee() { ... } public void setAssignee(String assignee) { ... } } JAXB runtime can read these annotations and create unmarshaller to parse XML into an object instance or marshall an object into XML. JAXB ships a schema compiler (XJC) which can generate annotated

Javascript: wait until ajax request finishes to close page [duplicate]

有些话、适合烂在心里 提交于 2019-12-28 04:08:27
问题 This question already has answers here : JavaScript, browsers, window close - send an AJAX request or run a script on window closing (9 answers) Closed 2 years ago . I would like the browser to keep the page open until the ajax requests are sent. This is what I imagine it would look like var requestsPending = 0; window.onbeforeunload = function() { showPleaseWaitMessage(); while(requestsPending > 0); } // called before making ajax request, atomic somehow function ajaxStarted() {

dwr网上使用例子

北慕城南 提交于 2019-12-27 20:25:32
转: dwr实现聊天室功能 2016年01月15日 10:22:43 我爱喝可乐 阅读数:564 用dwr的comet(推)来实现简单的无刷新多人聊天室,comet是长连接的一种。通常我们要实现无刷新,一般会使用到Ajax。Ajax 应用程序可以使用两种基本的方法解决这一问题:一种方法是浏览器每隔若干秒时间向 服务器 发出轮询以进行更新,另一种方法是服务器始终打开与浏览器的连接并在数据可用时发送给浏览器。第一种方法一般利用setTimeout或是setInterval定时请求,并返回最新数据,这无疑增加了服务器的负担,浪费了大量的资源。而第二种方法也会浪费服务器资源,长期的建立连接;而相对第一种来说,第二种方式会更优于第一种方法;这里有一个一对多和多对一的关系,而comet向多个客户端推送数据就是一对多的关系。而具体使用哪种方式,要看你当前的需求而定,没有绝对的。 为什么使用Comet? 轮询方法的主要缺点是:当扩展到更多客户机时,将生成大量的通信量。每个客户机必须定期访问服务器以检查更新,这为服务器资源添加了更多负荷。最坏的一种情况是对不频繁发生更新的应用程序使用轮询,例如一种 Ajax 邮件 Inbox。在这种情况下,相当数量的客户机轮询是没有必要的,服务器对这些轮询的回答只会是 “没有产生新数据”。虽然可以通过增加轮询的时间间隔来减轻服务器负荷,但是这种方法会产生不良后果

Logging user activity in web app

筅森魡賤 提交于 2019-12-27 19:13:58
问题 I'd like to be able to log user activities in a web app. I'm currently using log4j which works well for logging errors etc, but I'm unsure what the best approach is to log the user, executed servlet method, and method params. I'm using spring security for the authentication. A typical servlet could look like: public class BankAccountServlet { @RequestMapping("/deposit") public void deposit(double amount) { ... } @RequestMapping("/checkBalance") public double checkBalance() { ... } } If there

Logging user activity in web app

南楼画角 提交于 2019-12-27 19:13:30
问题 I'd like to be able to log user activities in a web app. I'm currently using log4j which works well for logging errors etc, but I'm unsure what the best approach is to log the user, executed servlet method, and method params. I'm using spring security for the authentication. A typical servlet could look like: public class BankAccountServlet { @RequestMapping("/deposit") public void deposit(double amount) { ... } @RequestMapping("/checkBalance") public double checkBalance() { ... } } If there

How to use DWR(Direct web remoting) in Spring MVC 4

风流意气都作罢 提交于 2019-12-25 02:58:26
问题 I am using dwr for first time should I use dwr ? If yes the How to use DWR(Direct web remoting) in Spring MVC 4. If not then what to use? 回答1: Yes, you can use DWR on spring project for Ajax kindof purpose. It can be easily implemented with one controller file and with xml file. All we have to do is call the method which is in controller from your script file. 回答2: create Bean on dispatch servlet <bean id="dwrBean" class="dwrController"> <property name="myDAO" ref="MyDAOImpl" /> </bean> Then

DWR sometimes die on the GAE server

 ̄綄美尐妖づ 提交于 2019-12-24 09:38:01
问题 I'm creating web app on the Google App Engine. For the AJAX calling I use DWR. Latest DWR version doesn't work fine with gae, because of that I work with 2.0.6 version of the DWR. On the local machine application works good. But on the Google server some methods called with errors. I only get errors in browser console (server logs are clear): Any ideas? Why the behavior on the local and the server machines is different? Thanks 回答1: I found mistake in my server side code. DWR 2 works fine for

Chrome data compression proxy and DWR

笑着哭i 提交于 2019-12-22 19:23:30
问题 We are developing a web mobile application using DWR as Ajax framework and we are getting errors in Nexus 4 devices which have enabled the option Reduce data usage in the Bandwidth Management setting. The error displays an alert saying Error 502: Bad gateway and it happens when refreshing a page that calls a DWR method in the onload event. 回答1: (I am the lead on the Chrome data compression proxy.) The problem is a bug in the DWR library which uses JavaScript comments to contain semantically