[ 
https://issues.apache.org/jira/browse/JSPWIKI-566?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14297429#comment-14297429
 ] 

brushed commented on JSPWIKI-566:
---------------------------------

Hi David,

The current JSPWiki default template still uses mootools v1.11. with older 
API's.
(documentation is still available at  
http://docs111.mootools.net/Remote/Json-Remote.js )

The newer Haddock template uses the latest mootools  >v1.4, 
with the Request.HTML and Request.JSON API's.
(documentation at http://mootools.net/core/docs/1.5.1/Request/Request.HTML )


So, only for the default template, try to change this in jspwiki-common.js :
{noformat}
+       ajaxHtmlCall:function(url, params, responseId, loading){
+               var update = document.getElementById(responseId);
+               if (update){ update.innerHTML = loading||'Loading...'; }
  
-               if (Wiki.JsonUrl) {
-               new Ajax( Wiki.JsonUrl, {
-                       postBody: Json.toString({"id":Wiki.$jsonid++, 
"method":method, "params":params}),
-                       method: 'post',
-                       onComplete: function(result){
-                               var r = Json.evaluate(result,true);
-                               if(r){
-                                       if(r.result){ fn(r.result) }
-                                       else if(r.error){ fn(r.error) }
-                               }
+               new Request.HTML({     
+                       url: this.JsonUrl + url,
+                       method:'post',  // defaults to 'POST'
+                       update: update
+               }).send({
+               params: params
+           });
+       },

{noformat}
into this
{noformat}
+       ajaxHtmlCall:function(url, params, responseId, loading){
+               var update = document.getElementById(responseId);
+               if (update){ update.innerHTML = loading||'Loading...'; }

+       if (this.JsonUrl) {
+               new Ajax( this.JsonUrl + url, {
+                       method:'post',  // defaults to 'POST'
+                       data: Json.toString(params),
+                       update: update,
+               }).request();
+       }
+

{noformat}


And this
{noformat}
+       ajaxJsonCall: function(url, params, callback){
+               //the Request.JSON does all encoding and decoding of the JSON 
automatically
+               new Request.JSON({
+                       url: this.JsonURL + url,
+                       method:'post', 
...
{noformat}
into this
{noformat}
+       ajaxJsonCall: function(url, params, callback){
+               //the Request.JSON does all encoding and decoding of the JSON 
automatically
+               new Json.Remote( url: this.JsonURL + url, {
+                       method:'post', 
...
{noformat}


I didn't test this out, so some tweaks may be needed.

dirk


> 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, 
> 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)

Reply via email to