Updated Branches: refs/heads/master 0e2fc3605 -> 8d24cbdd2
Add some better documentation for t5/core/dom:ajaxRequest and t5/core/ajax Rename option.parameters to option.data Rationale: the data is only parameters for the default content type; if the content type is changed, the data might be something else, such as text/json content. Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/8d24cbdd Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/8d24cbdd Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/8d24cbdd Branch: refs/heads/master Commit: 8d24cbdd2846002cf86bf4e3ca1640ec2560dfdb Parents: 0e2fc36 Author: Howard M. Lewis Ship <[email protected]> Authored: Mon Aug 5 09:51:07 2013 -0700 Committer: Howard M. Lewis Ship <[email protected]> Committed: Mon Aug 5 09:51:15 2013 -0700 ---------------------------------------------------------------------- .../coffeescript/META-INF/modules/t5/core/ajax.coffee | 11 +++++++++++ .../META-INF/modules/t5/core/ajaxformloop.coffee | 2 +- .../coffeescript/META-INF/modules/t5/core/alert.coffee | 2 +- .../META-INF/modules/t5/core/autocomplete.coffee | 2 +- .../META-INF/modules/t5/core/datefield.coffee | 4 ++-- .../META-INF/modules/t5/core/exception-frame.coffee | 2 +- .../coffeescript/META-INF/modules/t5/core/tree.coffee | 2 +- .../coffeescript/META-INF/modules/t5/core/zone.coffee | 2 +- .../org/apache/tapestry5/t5-core-dom.coffee | 8 ++++---- 9 files changed, 23 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee index 216b633..d2c968d 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajax.coffee @@ -17,6 +17,17 @@ # Exports a single function, that invokes `t5/core/dom:ajaxRequest()` with the provided `url` and a modified version of the # `options`. # +# * options.method - "post", "get", etc., default: "post". +# * options.contentType - request content, defaults to "application/x-www-form-urlencoded" +# * options.data - optional, additional key/value pairs (for the default content type) +# * options.success - handler to invoke on success. Passed the ResponseWrapper object. +# Default does nothing. +# * options.failure - handler to invoke on failure (server responds with a non-2xx code). +# Passed the response. Default will throw the exception +# * options.exception - handler to invoke when an exception occurs (often means the server is unavailable). +# Passed the exception. Default will generate an exception message and throw an `Error`. +# Note: not really supported under jQuery, a hold-over from Prototype. +# # It wraps (or provides) `success`, `exception`, and `failure` handlers, extended to handle a partial page render # response (for success), or properly log a server-side failure or client-side exception, including using the # `t5/core/exception-frame` module to display a server-side processing exception. http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee index 1a29d1b..09f6f3b 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee @@ -34,7 +34,7 @@ define ["./dom", "./events", "./console", "./ajax"], url = afl.attribute "data-remove-row-url" ajax url, - parameters: + data: "t:rowvalue": @attribute "data-afl-row-value" success: => # The server has removed the row from persistent storage, lets http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee index 0466687..0a015e6 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/alert.coffee @@ -55,7 +55,7 @@ define ["./dom", "./console", "./messages", "./ajax", "underscore"], return ajax (getURL container), - parameters: { id } + data: { id } success: -> removeAlert container, alert setupUI = (outer) -> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee index c560a1c..c86df25 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/autocomplete.coffee @@ -22,7 +22,7 @@ define ["./dom", "./ajax", "jquery", "bootstrap"], $field.addClass "ajax-wait" ajax url, - parameters: + data: "t:input": query success: (response) -> $field.removeClass "ajax-wait" http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee index 8c4948f..84b1ac7 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/datefield.coffee @@ -82,7 +82,7 @@ define ["./dom", "./events", "./messages", "./ajax", "underscore", "./fields"], @field.addClass "ajax-wait" ajax (@container.attribute "data-parse-url"), - parameters: + data: input: value onerror: (message) => @field.removeClass "ajax-wait" @@ -132,7 +132,7 @@ define ["./dom", "./events", "./messages", "./ajax", "underscore", "./fields"], ajax (@container.attribute "data-format-url"), - parameters: + data: input: date.getTime() failure: (response, message) => @field.removeClass "ajax-wait" http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/exception-frame.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/exception-frame.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/exception-frame.coffee index dc1a34b..759a4b9 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/exception-frame.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/exception-frame.coffee @@ -14,7 +14,7 @@ # ## t5/core/exception-frame # -# Manages a special element used to present a HTML exception report from an Ajax request (where a non-markup response +# Manages a special element used to present an HTML exception report from an Ajax request (where a non-markup response # was expected, including a partial page render response). define ["./dom", "underscore"], (dom, _) -> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee index 5d89663..65ece69 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/tree.coffee @@ -31,7 +31,7 @@ define ["./dom", "./ajax", "./zone"], url = container.attribute "data-tree-action-url" ajax url, - parameters: + data: "t:action": action "t:nodeid": node.attribute NODE_ID success: success http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee index 152a212..3ec463b 100644 --- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee +++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee @@ -105,7 +105,7 @@ define ["./dom", "./events", "./ajax", "./console", "./forms", "underscore"], parameters = attr and JSON.parse attr ajax event.memo.url, - parameters: _.extend { "t:zoneid": zone.element.id }, parameters, event.memo.parameters + data: _.extend { "t:zoneid": zone.element.id }, parameters, event.memo.parameters success: (response) => zone.trigger events.zone.update, content: response.json?.content http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/8d24cbdd/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee index eac41fd..f5e2db3 100644 --- a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee +++ b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee @@ -674,8 +674,8 @@ define ["underscore", "./utils", "./events", "jquery"], # render reponse keys. # # * options.method - "post", "get", etc., default: "post". - # * options.contentType - default "context "application/x-www-form-urlencoded" - # * options.parameters - optional, additional key/value pairs + # * options.contentType - request content, defaults to "application/x-www-form-urlencoded" + # * options.data - optional, additional key/value pairs (for the default content type) # * options.success - handler to invoke on success. Passed the ResponseWrapper object. # Default does nothing. # * options.failure - handler to invoke on failure (server responds with a non-2xx code). @@ -691,7 +691,7 @@ define ["underscore", "./utils", "./events", "jquery"], type: options.method?.toUpperCase() or "POST" contentType: options.contentType traditional: true - data: options.parameters + data: options.data # jQuery doesn't have the equivalent of Protoype's onException error: (jqXHR, textStatus, errorThrown) -> message = "Request to #{url} failed with status #{textStatus}" @@ -715,7 +715,7 @@ define ["underscore", "./utils", "./events", "jquery"], finalOptions = method: options.method or "post" contentType: options.contentType or "application/x-www-form-urlencoded" - parameters: options.parameters or {} + parameters: options.data onException: (ajaxRequest, exception) -> if options.exception options.exception exception
