Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get response from server, but no results are displayed in the panel yet

  • Loading branch information...
commit fc041d73ee4136174e1fdfaf2099f86c149e94af 1 parent 7f49796
@sparkica sparkica authored
View
4 .classpath
@@ -26,8 +26,6 @@
<classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/opencsv-2.2.jar"/>
<classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/rhino-1.7R2.jar"/>
<classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/secondstring-20100303.jar"/>
- <classpathentry kind="lib" path="/Users/fadi/development/Java/orefine/OpenRefine/main/webapp/WEB-INF/lib/signpost-commonshttp4-1.2.1.2.jar"/>
- <classpathentry kind="lib" path="/Users/fadi/development/Java/orefine/OpenRefine/main/webapp/WEB-INF/lib/signpost-core-1.2.1.2.jar"/>
<classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/slf4j-log4j12-1.5.6.jar"/>
<classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/velocity-1.5.jar"/>
<classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/vicino-1.1.jar"/>
@@ -61,5 +59,7 @@
<classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/poi-ooxml-3.8-20120326.jar"/>
<classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/poi-ooxml-schemas-3.8-20120326.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/OpenRefine"/>
+ <classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib/signpost-commonshttp4-1.2.1.2.jar" sourcepath="/OpenRefine/main/webapp/WEB-INF/lib-src/signpost-commonshttp4-1.2.1.2-sources.jar"/>
+ <classpathentry kind="lib" path="/OpenRefine/main/webapp/WEB-INF/lib-src/signpost-core-1.2.1.2-sources.jar"/>
<classpathentry kind="output" path="module/MOD-INF/classes"/>
</classpath>
View
236 module/scripts/suggestterm.suggest.js
@@ -4,82 +4,180 @@
}
$.suggest("suggestterm",
- $.extend(true, {}, $.suggest.suggest.prototype, {
- create_item: function(data,response_data) {
- var css = this.options.css;
-
- var li = $("<li>").addClass(css.item);
- var name = $("<div>").addClass(css.item_name)
+ $.extend(
+ true,
+ {},
+ $.suggest.suggest.prototype,
+ {
+ create_item: function(data,response_data) {
+ console.log("---- create item ----");
+ var css = this.options.css;
+
+ var li = $("<li>").addClass(css.item);
+ var name = $("<div>").addClass(css.item_name)
+
+ .append($("<label>")
+ .append($.suggest.strongify(data.name,response_data.prefix)));
+ // this converts html escaped strings like "&amp;"
+ // back to "&"
+ data.name = name.text();
+ li.append(name);
+ name.prepend($("<div>").addClass(css.item_type).text(data.id));
+ //TODO very smelly hack to disable cache
+ $.suggest.cache = {};
+ return li;
+ },
+
+ request: function(value, cursor) {
+ console.log("---- request ---");
+ var self = this,
+ o = this.options;
+
+ var data = {};
+ var query = value;
+ data[o.query_param_name] = query;
+
+ clearTimeout(this.request.timeout);
+ console.log("Data before ajax call");
+ data["prefix"] = query;
+ data["type_strict"] = "classes";
+ data["type"] = theProject.id;
+
+ var url = o.service_url + o.service_path + "?" + $.param(data, true);
+ console.log(url);
+ console.log(data);
+
+ var ajax_options = {
+ url: o.service_url + o.service_path,
+ data: data,
+ traditional: true,
+/* beforeSend: function(xhr) {
+ console.log("--- before send ---");
+ console.log(xhr);
+ var calls = self.input.data("request.count.suggest") || 0;
+ calls += 1;
+ self.trackEvent(self.name, "request", "count", calls);
+ self.input.data("request.count.suggest", calls);
+ },
+*/ error: function(xhr) {
+ console.log("--- request error --");
+ console.log(xhr);
+ self.status_error();
+
+ self.trackEvent(self.name, "request", "error", {
+ url: this.url,
+ response: xhr ? xhr.responseText : ''
+ });
+ self.input.trigger("fb-error", Array.prototype.slice.call(arguments));
+ },
+ complete: function(xhr) {
+ console.log(" -- complete --");
+ if (xhr) {
+ self.trackEvent(self.name, "request", "tid",
+ xhr.getResponseHeader("X-Metaweb-TID"));
+ }
+ },
+ success: function(data) {
+ console.log("--- success ---");
+ console.log(data);
+ $.suggest.cache[url] = data;
+ data.prefix = value; // keep track of prefix to match up response with input value
+ self.response(data, cursor ? cursor : -1);
+
+ },
+ dataType: "json",
+ cache: true
+ };
+ this.request.timeout = setTimeout(function() {
+ console.log("Doing something...");
+ $.ajax(ajax_options);
+ }, o.xhr_delay);
- .append($("<label>")
- .append($.suggest.strongify(data.name,response_data.prefix)));
- // this converts html escaped strings like "&amp;"
- // back to "&"
- data.name = name.text();
- li.append(name);
- name.prepend($("<div>").addClass(css.item_type).text(data.id));
- //TODO very smelly hack to disable cache
- $.suggest.cache = {};
- return li;
- },
-
- flyout_request:function(data){
-
- var self = this;
-
- var o = this.options,
- sug_data = this.flyoutpane.data("data.suggest");
- if (sug_data && data.id === sug_data.id) {
- if (!this.flyoutpane.is(":visible")) {
- var s = this.get_selected();
- this.flyout_position(s);
- this.flyoutpane.show();
- this.input.trigger("fb-flyoutpane-show", this);
- }
- return;
- }
+ },
+
+ response: function(data){
+ console.log("---- response ----");
+ console.log(data);
+ var o = this.options,
+ p = this.pane,
+ s = this.get_selected() || [];
+ if (p.is(":visible") && s.length) {
+ var sug_data = s.data("data.suggest");
+ if (sug_data && data.id === sug_data.id) {
+ this.flyoutpane.html('<div class="fbs-flyout-content">' + data.description + '</div>');
+ this.flyout_position(s);
+ this.flyoutpane.show()
+ .data("data.suggest", sug_data);
+ this.input.trigger("fb-flyoutpane-show", this);
+ }
+ }
- // check $.suggest.flyout.cache
- var cached = $.suggest.flyout.cache[data.id];
- if (cached) {
- this.flyout_response(cached);
- return;
- }
-
- clearTimeout(this.flyout_request.timeout);
- this.flyout_request.timeout =
- setTimeout(function(){self.flyout_response(data);}, o.xhr_delay);
-
- },
-
- flyout_response:function(data){
- var o = this.options,
- p = this.pane,
- s = this.get_selected() || [];
- if (p.is(":visible") && s.length) {
- var sug_data = s.data("data.suggest");
- if (sug_data && data.id === sug_data.id) {
- this.flyoutpane.html('<div class="fbs-flyout-content">' + data.description + '</div>');
- this.flyout_position(s);
- this.flyoutpane.show()
- .data("data.suggest", sug_data);
- this.input.trigger("fb-flyoutpane-show", this);
- }
- }
- }
+ },
+
+ flyout_request:function(data){
+ console.log("----- flyout request ---");
+
+ var self = this;
+
+ var o = this.options,
+ sug_data = this.flyoutpane.data("data.suggest");
+ if (sug_data && data.id === sug_data.id) {
+ if (!this.flyoutpane.is(":visible")) {
+ var s = this.get_selected();
+ this.flyout_position(s);
+ this.flyoutpane.show();
+ this.input.trigger("fb-flyoutpane-show", this);
+ }
+ return;
+ }
+
+ // check $.suggest.flyout.cache
+ var cached = $.suggest.flyout.cache[data.id];
+ if (cached) {
+ this.flyout_response(cached);
+ return;
+ }
+
+ clearTimeout(this.flyout_request.timeout);
+ this.flyout_request.timeout =
+ setTimeout(function(){self.flyout_response(data);}, o.xhr_delay);
+
+ },
+
+ flyout_response:function(data){
+ console.log("---- flyout response ----");
+ var o = this.options,
+ p = this.pane,
+ s = this.get_selected() || [];
+ if (p.is(":visible") && s.length) {
+ var sug_data = s.data("data.suggest");
+ if (sug_data && data.id === sug_data.id) {
+ this.flyoutpane.html('<div class="fbs-flyout-content">' + data.description + '</div>');
+ this.flyout_position(s);
+ this.flyoutpane.show()
+ .data("data.suggest", sug_data);
+ this.input.trigger("fb-flyoutpane-show", this);
+ }
+ }
+ }
}));
$.extend($.suggest.suggestterm, {
- defaults: $.extend(true, {}, $.suggest.suggest.defaults, {
- service_url: "",
- service_path: "command/rdf-extension/suggest-term",
- type_strict:"classes",
- suggest_new:"Add it",
- cache:false,
-// soft:true,
- nomatch:'<em class="fbs-nomatch-text">No suggested matches. (Shift + Enter) to add it</em>'
+ defaults: $.extend(
+ true,
+ {},
+ $.suggest.suggest.defaults,
+ {
+ service_url: "",
+ service_path: "command/rdf-extension/suggest-term",
+ flyout_service_path: "command/rdf-extension/suggest-term",
+ type_strict:"classes",
+ suggest_new:"Add it",
+ cache:false,
+ // soft:true,
+ nomatch:'<em class="fbs-nomatch-text">No suggested matches. (Shift + Enter) to add it</em>'
})
});
View
3  src/org/deri/grefine/rdf/commands/SuggestTermCommand.java
@@ -38,8 +38,9 @@ public void doGet(HttpServletRequest request, HttpServletResponse response)
String projectId = request.getParameter("type");
response.setHeader("Content-Type", "application/json");
- JSONWriter writer = new JSONWriter(response.getWriter());
+ //response.setStatus(HttpServletResponse.SC_OK);
+ JSONWriter writer = new JSONWriter(response.getWriter());
String type = request.getParameter("type_strict");
String query = request.getParameter("prefix");
Please sign in to comment.
Something went wrong with that request. Please try again.