diff --git a/src/org/wescheme/data/Feedback.java b/src/org/wescheme/data/Feedback.java index bebb2f18..136e7a74 100644 --- a/src/org/wescheme/data/Feedback.java +++ b/src/org/wescheme/data/Feedback.java @@ -45,7 +45,9 @@ public JSONObject toJSONObject() { obj.put("id", this.id); obj.put("author", this.author); obj.put("type", this.type); - obj.put("date", this.date); + obj.put("feedbackText", this.feedbackText); + // date is represented at amount of milliseconds since the epoch. + obj.put("date", this.date.getTime()); return obj; } } diff --git a/src/org/wescheme/servlet/DumpFeedback.java b/src/org/wescheme/servlet/DumpFeedback.java index 7a6c0e32..fc6ae789 100644 --- a/src/org/wescheme/servlet/DumpFeedback.java +++ b/src/org/wescheme/servlet/DumpFeedback.java @@ -3,11 +3,13 @@ import java.io.IOException; import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.json.simple.JSONArray; import org.json.simple.JSONObject; +import org.wescheme.data.DAO; import org.wescheme.data.Feedback; import org.wescheme.user.Session; import org.wescheme.user.SessionManager; @@ -34,7 +36,7 @@ * @author dyoo * */ -public class DumpFeedback { +public class DumpFeedback extends HttpServlet { public static final long LIMIT_MILLIS = 1000 * 25; // provide a little leeway @@ -47,6 +49,9 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro response.sendError(401); return; } + + // Side effect: force loading of the classes. + DAO dao = new DAO(); // Next, start dumping content till we hit CPU limit diff --git a/war-src/js/ajaxactions.js b/war-src/js/ajaxactions.js index 8ed340d7..99fe27fe 100644 --- a/war-src/js/ajaxactions.js +++ b/war-src/js/ajaxactions.js @@ -173,4 +173,25 @@ goog.require('plt.wescheme.Program'); xhr: function(settings) { return new XMLHttpRequest(settings); } }); }; + + + plt.wescheme.AjaxActions.prototype.sendFeedback = function(author, type, feedbackText, onSuccess) { + jQuery.ajax({cache : false, + data : {author : author, + type : type, + feedbackText : feedbackText }, + datatype: "text", + type: "POST", + url: "/addFeedback", + success: function(data) { + onSuccess(); + }, + error: function(xhr) { + onSuccess(); + }, + xhr: function(settings) { return new XMLHttpRequest(settings); } + }); + + }; + })(); \ No newline at end of file