From 025706049a03269ff69b82b77321d1b7e0d24804 Mon Sep 17 00:00:00 2001 From: Lars Michaelis Date: Wed, 2 Dec 2015 11:19:26 +0100 Subject: [PATCH 1/5] Initial commit --- jsf/jsf-tests.ts | 3 ++ jsf/jsf.d.ts | 72 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 jsf/jsf-tests.ts create mode 100644 jsf/jsf.d.ts diff --git a/jsf/jsf-tests.ts b/jsf/jsf-tests.ts new file mode 100644 index 000000000..c944bc72d --- /dev/null +++ b/jsf/jsf-tests.ts @@ -0,0 +1,3 @@ +/// + +import jsf = require("jsf"); diff --git a/jsf/jsf.d.ts b/jsf/jsf.d.ts new file mode 100644 index 000000000..14f7b407d --- /dev/null +++ b/jsf/jsf.d.ts @@ -0,0 +1,72 @@ +// Type definitions for for the JSF 2.0 Ajax request API. +// Project: https://docs.oracle.com/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/js-api/symbols/jsf.ajax.html +// Definitions by: Lars Michaelis and Stephan Zerhusen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "jsf" { + module ajax { + + interface RequestData { + status: string; + description: string; + } + + interface RequestOptions { + /** + * space seperated list of client identifiers + */ + execute?: String; + + /** + * space seperated list of client identifiers + */ + render?: String; + + /** + * function to callback for event + * @param callback the callback function + */ + onevent?(callback:(data:RequestData) => void): void; + + /** + * function to callback for error + * @param callback the callback function + */ + onerror?(callback:(data:RequestData) => void): void; + + /** + * object containing parameters to include in the request + */ + params?: any; + } + + /** + * Register a callback for event handling. + * @param callback a reference to a function to call on an event + */ + function addOnEvent(callback:(data:RequestData) => void):void; + + /** + * Register a callback for error handling. + * @param callback a reference to a function to call on an error + */ + function addOnError(callback:(data:RequestData) => void):void; + + /** + * Send an asynchronous Ajax request to the server. + * @param source The DOM element that triggered this Ajax request, or an id string of the element to use as the triggering element. + * @param event The DOM event that triggered this Ajax request. The event argument is optional. + * @param options The set of available options that can be sent as request parameters to control client and/or server side request processing. + */ + function request(source:any, event?:String, options?:RequestOptions):void; + + /** + * Receive an Ajax response from the server. + * @param request The XMLHttpRequest instance that contains the status code and response message from the server. + * @param context An object containing the request context, including the following properties: the source element, per call onerror callback function, and per call onevent callback function. + * @throws EmptyResponse error if request contains no data + */ + function response(request:any, context:any):void; + + } +} From 56b3481c312ea9318b10b7f26df2b269c247c92d Mon Sep 17 00:00:00 2001 From: Lars Michaelis Date: Wed, 2 Dec 2015 11:30:10 +0100 Subject: [PATCH 2/5] make it compile with npm test --- jsf/jsf-tests.ts | 1 - jsf/jsf.d.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/jsf/jsf-tests.ts b/jsf/jsf-tests.ts index c944bc72d..b56749a4a 100644 --- a/jsf/jsf-tests.ts +++ b/jsf/jsf-tests.ts @@ -1,3 +1,2 @@ /// -import jsf = require("jsf"); diff --git a/jsf/jsf.d.ts b/jsf/jsf.d.ts index 14f7b407d..9c7f6a43d 100644 --- a/jsf/jsf.d.ts +++ b/jsf/jsf.d.ts @@ -1,6 +1,6 @@ -// Type definitions for for the JSF 2.0 Ajax request API. +// Type definitions for for the JSF 2.0 Ajax request API // Project: https://docs.oracle.com/cd/E17802_01/j2ee/javaee/javaserverfaces/2.0/docs/js-api/symbols/jsf.ajax.html -// Definitions by: Lars Michaelis and Stephan Zerhusen +// Definitions by: Lars Michaelis and Stephan Zerhusen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "jsf" { From 2c123744f00cb74676333a45e1ef4f0750b3b39f Mon Sep 17 00:00:00 2001 From: Lars Michaelis Date: Wed, 2 Dec 2015 11:46:17 +0100 Subject: [PATCH 3/5] add tests --- jsf/jsf-tests.ts | 25 +++++++++++++++++++++++++ jsf/jsf.d.ts | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/jsf/jsf-tests.ts b/jsf/jsf-tests.ts index b56749a4a..3c594f1e5 100644 --- a/jsf/jsf-tests.ts +++ b/jsf/jsf-tests.ts @@ -1,2 +1,27 @@ /// +function callbackWithoutData() { + +} + +function callback(data: jsf.ajax.RequestData) { + +} + +class RequestOptionsImpl implements jsf.ajax.RequestOptions { + execute = "@all"; + render = "@none"; +} + + +jsf.ajax.addOnEvent(callbackWithoutData); +jsf.ajax.addOnEvent(callback); + +jsf.ajax.addOnError(callbackWithoutData); +jsf.ajax.addOnError(callback); + +jsf.ajax.request("someSource"); +jsf.ajax.request("someSource", "change"); +jsf.ajax.request("someSource", "change", new RequestOptionsImpl()); + +jsf.ajax.response("someRequestObject", "someContextObject"); diff --git a/jsf/jsf.d.ts b/jsf/jsf.d.ts index 9c7f6a43d..d19dafe0e 100644 --- a/jsf/jsf.d.ts +++ b/jsf/jsf.d.ts @@ -3,7 +3,7 @@ // Definitions by: Lars Michaelis and Stephan Zerhusen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare module "jsf" { +declare module jsf { module ajax { interface RequestData { From 722e48a621b68c5acae43f51373bd799731dfb74 Mon Sep 17 00:00:00 2001 From: Lars Michaelis Date: Wed, 2 Dec 2015 11:49:37 +0100 Subject: [PATCH 4/5] add tests --- jsf/jsf-tests.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jsf/jsf-tests.ts b/jsf/jsf-tests.ts index 3c594f1e5..76815bf9e 100644 --- a/jsf/jsf-tests.ts +++ b/jsf/jsf-tests.ts @@ -4,13 +4,13 @@ function callbackWithoutData() { } -function callback(data: jsf.ajax.RequestData) { +function callback(data:jsf.ajax.RequestData) { } class RequestOptionsImpl implements jsf.ajax.RequestOptions { execute = "@all"; - render = "@none"; + render = "@none"; } @@ -24,4 +24,4 @@ jsf.ajax.request("someSource"); jsf.ajax.request("someSource", "change"); jsf.ajax.request("someSource", "change", new RequestOptionsImpl()); -jsf.ajax.response("someRequestObject", "someContextObject"); +jsf.ajax.response("someRequestObject", {context: "someContextObject"}); From caa3cf3634551dfa745272e02dcdb78bce83a329 Mon Sep 17 00:00:00 2001 From: Lars Michaelis Date: Mon, 7 Dec 2015 16:21:26 +0100 Subject: [PATCH 5/5] rename folder from jsf to jee-jsf --- {jsf => jee-jsf}/jsf-tests.ts | 0 {jsf => jee-jsf}/jsf.d.ts | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {jsf => jee-jsf}/jsf-tests.ts (100%) rename {jsf => jee-jsf}/jsf.d.ts (100%) diff --git a/jsf/jsf-tests.ts b/jee-jsf/jsf-tests.ts similarity index 100% rename from jsf/jsf-tests.ts rename to jee-jsf/jsf-tests.ts diff --git a/jsf/jsf.d.ts b/jee-jsf/jsf.d.ts similarity index 100% rename from jsf/jsf.d.ts rename to jee-jsf/jsf.d.ts