💻 Client-Side JavaScript Library: EFW

The provided source code constitutes the client-side JavaScript library (efw.js and efw.client.js) for a framework called EFW.

The primary goal of this framework is to provide event-driven communication between the client (browser) and the server, along with the subsequent automation of UI operations.


🧪 Core Structure and Features

1. Efw Constructor (efw.js)

2. Global Instance and Properties (efw.js)

3. System Initialization (efw.js)


📡 EfwClient Communication Flow (efw.client.js)

The EfwClient.prototype.fire method contains the main logic for executing a server event.

1. Event Execution Sequence

Event execution essentially consists of the following two stages of Ajax communication (or WebSocket communication):

Step Method Purpose
Clear N/A Clears error displays (.efw_input_error).
URL Construction N/A Constructs URLs for efwServlet, uploadServlet, downloadServlet, previewServlet, and efwWebSocket.
Phase 1 _callFirstAjax Sends the event ID to the server to get the format of parameters (paramsFormat) the client should collect.
Parameter Collection _pickupParams Automatically collects data from HTML elements ($(key)) and manualParams based on the paramsFormat received from the server.
File Upload _callUploadAjax If file inputs (<input type="file">) are included, uploads the files using FormData.
Phase 2 _callSecondAjax / _callSecondAjaxInWsMode Sends the entire collected parameters to the server to get the event execution result (values, actions).
Result Reflection _showValues Automatically updates HTML element values based on the values returned from the server.
Action Execution _showActions Executes client-side operations (error display, element show/hide, navigation, download, etc.) based on the actions returned from the server.

2. Parameter Collection (_pickupParams)

3. Action Processing (_showActions)

The server can instruct the client to perform specific behaviors by returning an actions object.


💡 Summary

The provided source code is designed as a robust client framework to abstract and automate “bidirectional client-server communication” and “UI data binding/manipulation”. Developers can call Efw("eventId") to execute a server event, automatically collect parameters, display results, and perform UI actions, without writing verbose Ajax callback processing or DOM manipulation.