[
https://issues.apache.org/jira/browse/JSPWIKI-566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14291254#comment-14291254
]
brushed commented on JSPWIKI-566:
---------------------------------
Hi David,
I appreciate the work you are doing on the json-rpc. I believe your approach
simplifies
an greatly improves this capability in JSPWiki. Nice.
I do like the way the current json-rpc handles errors and supports flexible
parameters;
and would like to suggest to adopt a similar but simplified api, if possible.
Rather then encoding everything in the URL with "/", we could pass the method
and the
parameters as a JSON object to the server. (as post data)
Also the return data could be encoded as a JSON object { result: ..., error:
"error-message" }
Here is an example how the client side would look like :
{noformat}
ajaxJsonCall: function(method, params, callback){
//the Request.JSON does all encoding and decoding of the JSON automatically
new Request.JSON{{
url: this.JsonURL,
method:'post',
onSuccess: function(response){
if(response.error){
console.log(response.error);
callback(null);
} else {
callback(response.result)
}
},
onError: function(response){
console.log(response.error);
callback(null);
}
}).send({
//id: JSONid++ //strictly spoken not needed; but might be useful for
troubleshooting ?
method: method,
params: params
});
},
{noformat}
The method would be eg "search.findPages" separated with dots, and parameters
could be any other data.
{noformat}
AjaxJsonCall("search.findPages", ["test",20], function(result){ ... })
{noformat}
BTW, when using jQuery, this would be very similar, replacing new Request.JSON
by something like $.getJSON(...)
> AJAX server-side rewrite
> ------------------------
>
> Key: JSPWIKI-566
> URL: https://issues.apache.org/jira/browse/JSPWIKI-566
> Project: JSPWiki
> Issue Type: Improvement
> Components: Core & storage
> Affects Versions: 2.10.1
> Reporter: Janne Jalkanen
> Assignee: David Vittor
> Attachments: ajaxDispatchServlet.patch, ajaxFunctions.patch,
> ajaxFunctions.patch, ajaxFunctions.patch, ajaxFunctions.patch, test.html
>
>
> The AJAX library we're currently using is a bit problematic, as it stores
> non-serializable stuff in the HttpSession (causing all sorts of nasty
> exception reports in default configurations of Tomcat, and preventing
> clustering). It does provide a very nice, reflection-based interface so that
> we can expose any class/method as a JSON endpoint, but this does not really
> work well with our auth system.
> We should replace the jabsorb stuff with a Stripes-native solution (possibly
> with some extensions to allow particular beans to expose methods as if we
> were using jabsorb).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)