You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2026/08/27 12:52:27 UTC

(myfaces-tobago) 02/04: refactor: JavaScript API

This is an automated email from the ASF dual-hosted git repository.

henningn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 9d9057d90a8a96897e0e528a62a5155e6c283a9f
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Thu Aug 27 13:39:07 2026 +0200

    refactor: JavaScript API
    
    Currently, there is a JavaScript API for "tobago.ajax.request()" to use the Tobago Ajax queue. The JavaScript API is now moved from "tobago-ajax-queue.ts" to "tobago-api.ts" and the "tobago.faces.d.ts" is renamed to "tobago.d.ts" because in the future there might be more JavaScript API calls. The "tobago-api.ts" file is the place to implement this API.
    
    This is a preparation for TOBAGO-2515 where a new JS-API call will be implemented.
---
 .../src/main/ts/tobago-ajax-queue.ts               | 12 --------
 .../src/main/ts/tobago-api.ts                      | 32 ++++++++++++++++++++++
 .../src/main/ts/tobago-init.ts                     |  1 +
 .../src/main/ts/{tobago.faces.d.ts => tobago.d.ts} |  0
 4 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-ajax-queue.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-ajax-queue.ts
index 087d3db528..43c81c972e 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-ajax-queue.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-ajax-queue.ts
@@ -68,15 +68,3 @@ class AjaxQueue {
 }
 
 export const ajaxQueue = new AjaxQueue();
-
-/**
- * To use the Ajax queue from Tobago, replace "faces.ajax.request(...)" with "tobago.ajax.request(...)".
- * "tobago.ajax.request(...)" calls "faces.ajax.request(...)", so "faces.ajax.addOnEvent()" and "faces.ajax.addOnError"
- * still work.
- */
-(window as any).tobago = {
-  ajax: {
-    request: (elementOrId: Element | string, event?: Event, options?: faces.ajax.RequestOptions) =>
-        ajaxQueue.request(elementOrId, event, options)
-  }
-};
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-api.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-api.ts
new file mode 100644
index 0000000000..dad1544f38
--- /dev/null
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-api.ts
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import {ajaxQueue} from "./tobago-ajax-queue";
+
+(window as any).tobago = {
+  /**
+   * To use the Ajax queue from Tobago, replace "faces.ajax.request(...)" with "tobago.ajax.request(...)".
+   * "tobago.ajax.request(...)" calls "faces.ajax.request(...)", so "faces.ajax.addOnEvent()" and
+   * "faces.ajax.addOnError" still work.
+   */
+  ajax: {
+    request: (elementOrId: Element | string, event?: Event, options?: faces.ajax.RequestOptions) =>
+        ajaxQueue.request(elementOrId, event, options)
+  }
+};
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-init.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-init.ts
index f87e3c3332..303ab6918b 100644
--- a/tobago-theme/tobago-theme-standard/src/main/ts/tobago-init.ts
+++ b/tobago-theme/tobago-theme-standard/src/main/ts/tobago-init.ts
@@ -22,6 +22,7 @@ formal ordering rules:
 
 // custom elements
 import "./tobago-ajax-queue";
+import "./tobago-api";
 import "./tobago-bar";
 import "./tobago-date";
 import "./tobago-dropdown";
diff --git a/tobago-theme/tobago-theme-standard/src/main/ts/tobago.faces.d.ts b/tobago-theme/tobago-theme-standard/src/main/ts/tobago.d.ts
similarity index 100%
rename from tobago-theme/tobago-theme-standard/src/main/ts/tobago.faces.d.ts
rename to tobago-theme/tobago-theme-standard/src/main/ts/tobago.d.ts