Package com.oorian.html.js
Class JavaScriptApi
java.lang.Object
com.oorian.html.js.JavaScriptApi
- Direct Known Subclasses:
ClipboardApi,FullscreenApi,GeolocationApi,MediaDevicesApi,NavigationApi,NetworkApi,NotificationApi,PermissionsApi,ScreenApi,SelectionApi,ShareApi,SpeechApi,StorageApi,TimerApi,VibrationApi,VisibilityApi,WakeLockApi,WindowApi
Base class for JavaScript API wrappers providing access to browser functionality from server-side Java code.
This class provides the foundation for all JavaScript API classes in the Oorian framework.
It includes the core executeJs methods for executing arbitrary JavaScript on the client,
as well as utility methods for obtaining the current page context.
All methods are provided in two forms:
- Convenience form - No page parameter; uses thread-local page lookup
- Efficient form - Accepts page parameter; avoids thread-local lookup
Usage:
// Convenience - uses thread-local page lookup
JavaScriptApi.executeJs("console.log('Hello')");
// Efficient - passes page reference directly
JavaScriptApi.executeJs(this, "console.log('Hello')");
- Author:
- Marvin P. Warble Jr.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidExecutes a JavaScript statement on the client.static voidExecutes a JavaScript function on the client with the specified parameters.static voidExecutes a JavaScript statement on the client using the current page context.static voidExecutes a JavaScript function on the client with the specified parameters using the current page context.protected static HtmlPagegetPage()Returns the current page from the thread-local session context.
-
Constructor Details
-
JavaScriptApi
public JavaScriptApi()
-
-
Method Details
-
getPage
Returns the current page from the thread-local session context.- Returns:
- The current HtmlPage instance.
-
executeJs
Executes a JavaScript statement on the client using the current page context.- Parameters:
script- The JavaScript code to execute.
-
executeJs
Executes a JavaScript statement on the client.- Parameters:
page- The page to execute the script on.script- The JavaScript code to execute.
-
executeJs
Executes a JavaScript function on the client with the specified parameters using the current page context.- Parameters:
functionName- The JavaScript function name.parameters- The parameters to pass to the function.
-
executeJs
Executes a JavaScript function on the client with the specified parameters.- Parameters:
page- The page to execute the script on.functionName- The JavaScript function name.parameters- The parameters to pass to the function.
-