Skip to content

Conversation

Artur-
Copy link
Member

@Artur- Artur- commented Sep 30, 2025

Remove the complex array-based type wrapping system (NODE_TYPE, ARRAY_TYPE,
RETURN_CHANNEL_TYPE, BEAN_TYPE) in favor of a universal @v format that can
be used anywhere in the JSON tree.

Key changes:

  • Components: {"@v": "node", "id": nodeId} (was [0, nodeId])
  • Return channels: {"@v": "return", "nodeId": x, "channelId": y} (was [2, x, y])
  • Arrays: Use standard JSON arrays without wrapping
  • Beans: Use standard Jackson serialization with custom serializers

Benefits:

  • Simplified architecture with single universal system
  • Better performance using native JSON.parse with reviver
  • More extensible format for future types
  • Cleaner serialization logic without recursive type detection

Artur- and others added 6 commits September 29, 2025 17:37
Implemented server-to-client bean serialization with lazy Component resolution:

- Server-side: Added BEAN_TYPE=5 to JacksonCodec with custom Component serializer
  * Components serialize as {"__vaadinType": "component", "nodeId": <id>}
  * Uses Jackson ObjectMapper with field visibility configuration
  * Handles nested beans and arrays automatically

- Client-side: Added bean deserialization to ClientJsonCodec
  * Lazy component resolution - components are resolved when accessed
  * Native JavaScript function for component field access
  * Supports nested beans with component references

- Tests: Comprehensive test coverage
  * 6 client-side unit tests for bean deserialization
  * 3 integration tests covering simple beans, nested beans, and component references
  * All tests passing successfully

This enables sending complex Java beans with Component references from server to client via executeJs(), with automatic lazy resolution of components on the client side.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…adin

Changed the special key used to identify Vaadin-specific types in JSON
from "__vaadinType" to "@vaadin" to further avoid potential conflicts
with user data. This applies to Component references in bean serialization.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…texts

Changed single Component serialization to use the same format as Components
within beans:
- Single Components now serialize as [BEAN_TYPE, {"@vaadin": "component", "nodeId": <id>}]
- This provides consistency between single Component serialization and Component
  fields within beans
- Added BEAN_TYPE constant to JsonCodec for compatibility
- Added test coverage for single Component serialization

This unified format simplifies client-side handling and provides a consistent
API for all Component serialization scenarios.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Removed NODE_TYPE constant from JsonCodec and JacksonCodec
- Updated ClientJsonCodec to no longer handle NODE_TYPE format
- Fixed ExecuteJavaScriptProcessorTest to use new component format
- Updated decodeStateNode to handle new @vaadin component format
- Fixed JacksonCodecTest to expect new component format
- Added test for decodeStateNode with new component format
- Fixed test assertions to match actual behavior
- Clarified comment about GWT.isScript() check for compilation phase
- All Component references now use: {"@vaadin": "component", "nodeId": <id>}

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vaadin-bot
Copy link
Collaborator

vaadin-bot commented Sep 30, 2025

TC Format Checker Report - 10:00 - 30 - Sep

BLOCKER There are 6 files with format errors

  • To see a complete report of formatting issues, download the differences file

  • To fix the build, please run mvn formatter:format in your branch and commit the changes.

  • Optionally you might add the following line in your .git/hooks/pre-commit file:

    mvn formatter:format
    

Here is the list of files with format issues in your PR:

flow-client/src/main/java/com/vaadin/client/flow/util/ClientJsonCodec.java
flow-client/src/test/java/com/vaadin/client/flow/util/ClientJsonCodecTest.java
flow-server/src/main/java/com/vaadin/flow/internal/JacksonCodec.java
flow-server/src/main/java/com/vaadin/flow/internal/JsonCodec.java
flow-server/src/test/java/com/vaadin/flow/internal/BeanSerializationTest.java
flow-server/src/test/java/com/vaadin/flow/internal/JacksonCodecTest.java

Remove the complex array-based type wrapping system (NODE_TYPE, ARRAY_TYPE,
RETURN_CHANNEL_TYPE, BEAN_TYPE) in favor of a universal @v format that can
be used anywhere in the JSON tree.

Key changes:
- Components: {"@v": "node", "id": nodeId} (was [0, nodeId])
- Return channels: {"@v": "return", "nodeId": x, "channelId": y} (was [2, x, y])
- Arrays: Use standard JSON arrays without wrapping
- Beans: Use standard Jackson serialization with custom serializers

Benefits:
- Simplified architecture with single universal system
- Better performance using native JSON.parse with reviver
- More extensible format for future types
- Cleaner serialization logic without recursive type detection

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Artur- Artur- force-pushed the execjs-bean-plus-refactor branch from 6fe33cd to 97d7ed2 Compare September 30, 2025 09:55
Copy link

Copy link

Test Results

1 167 files   - 101  1 167 suites   - 101   1h 37m 40s ⏱️ + 20m 59s
8 415 tests  - 265  8 295 ✅  - 318  62 💤  -  5  47 ❌ +47  11 🔥 +11 
8 603 runs   - 542  8 469 ✅  - 599  67 💤  - 10  55 ❌ +55  12 🔥 +12 

For more details on these failures and errors, see this check.

Results for commit 97d7ed2. ± Comparison against base commit 236a649.

This pull request removes 288 and adds 23 tests. Note that renamed tests count towards both.
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeStateNode_node
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeWithTypeInfo_element
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ testDecodeWithoutTypeInfo_arrayUnsupported
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ testDecodeWithoutTypeInfo_objectUnsupported
com.vaadin.flow.AddQueryParamIT(production) ‑ validateRouterInUse[any_Chrome_]
com.vaadin.flow.FlowInReactComponentIT(production) ‑ validateComponentPlacesAndFunction[any_Chrome_]
com.vaadin.flow.HistoryIT(production) ‑ testHistory[any_Chrome_]
com.vaadin.flow.NavigationEventsIT(production) ‑ assertNavigationToSelfProducesNavigationEvents[any_Chrome_]
com.vaadin.flow.NavigationTriggerIT(production) ‑ testNavigationTriggers[any_Chrome_]
com.vaadin.flow.PopStateHandlerIT(production) ‑ testDifferentPath_ServerSideEvent[any_Chrome_]
…
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeStateNode_bean
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeStateNode_directComponentReference
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeWithTypeInfo_beanWithComponent
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeWithTypeInfo_beanWithComponentArray
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeWithTypeInfo_beanWithNullComponent
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeWithTypeInfo_beanWithUnattachedComponent
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeWithTypeInfo_directComponentReference
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeWithTypeInfo_directComponentReferenceWithNullNodeId
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ decodeWithTypeInfo_nestedBeansWithComponents
com.vaadin.client.flow.util.ClientJsonCodecTest ‑ testDecodeWithoutTypeInfo_arraySupported
…

@Artur-
Copy link
Member Author

Artur- commented Oct 2, 2025

In #22396

@Artur- Artur- closed this Oct 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants