efw Framework Output Test Example

Overview

Output Test is a complete example demonstrating the data output functionality in the efw framework, showing how to dynamically populate various HTML form elements with JSON data. This example includes both frontend JSP pages and backend JavaScript event handling logic.

Core Files

  1. JSP Page: OutputTest.jsp
  2. JavaScript Event Handling: OutputTest_display.js

Functionality Implementation

1. Data Source Definition

2. Data Processing Flow

  1. User clicks the “Batch Display” button to trigger the Efw('OutputTest_display') event
  2. Backend JavaScript parses JSON data from three text areas
  3. Uses chain operations to populate page elements:
    • Dropdown Lists: Clear existing options → Add new options
    • Tables: Preserve headers → Add data rows
    • Other Elements: Set values based on selectors

3. Supported Input Types

Type Example Element Data Processing Method
Text Input #item1 Directly set value
Hidden Field #item2 Set value but don’t display
Special Input #item5 (Phone) Format validation
DateTime #item9 Specific format processing
Number Range #item16 Numeric conversion
Color Picker #item17 Hexadecimal value processing
Checkbox #item18 Set checked status based on value
Radio Button [name=item19] Select corresponding option based on value
Dropdown List #item20 Set selected item
Multi-select List #item21 Set multiple selected items
Text Area #item22 Set text content
Data Table #item23 Dynamically generate row data

Technical Highlights

1. Declarative Data Mapping

2. Template-Driven Rendering

3. Chain Operation API

new Result()
  .runat(selector)
  .remove(elements)
  .append(template)
  .withdata(data)

4. Batch Operation Support

5. JSON Data-Driven

Usage Scenarios

This example is suitable for:

Through this example, developers can learn how the efw framework efficiently populates various HTML form elements with JSON data, achieving separation of data and view.