Skip to content

docs: show how to send events between components in the same UI - #6256

Draft
totally-not-ai[bot] wants to merge 2 commits into
mainfrom
docs/ui-scoped-component-events
Draft

totally-not-ai[bot] wants to merge 2 commits into
mainfrom
docs/ui-scoped-component-events

Conversation

@totally-not-ai

@totally-not-ai totally-not-ai Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Review risk: two-way door — adds one section and three example classes to the component events reference page; nothing existing changes.

Summary

Adds a Communicating Between Components in the Same UI section to articles/flow/component-internals/events.adoc. It shows how to use the UI's event bus to send events between components that don't have references to each other. The example is a search field in the main layout that tells the current view to filter its content.

The docs so far only showed an event bus stored in the session. Firing events on the UI with ComponentUtil.fireEvent() / ComponentUtil.addListener() wasn't documented anywhere.

What changed

  • New section after "Firing Events from the Server". It covers:
    • Firing a ComponentEvent on the UI with ComponentUtil.fireEvent().
    • Listening with ComponentUtil.addListener() inside whenAttached(), so the listener is removed on detach and the UI doesn't keep a reference to a detached view.
    • When to use something else: an event bus in the VaadinSession to reach all of the user's tabs, or a local signal when the components share state rather than react to events.
  • New compiled examples SearchEvent, GlobalSearchField and OrdersView in com.vaadin.demo.reference.componentinternals.events.ui.

This replaces the "Communicate between components attached to one UI" recipe from the retired Vaadin Cookbook.

Test summary

  • The new example classes compile with the rest of the docs sources (mvn compile).

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Preview Deployment

This PR has been deployed for preview.

URL: https://docs-preview-pr-6256.fly.dev

Changed pages

Added content is highlighted in green; removed content is marked in red on each page.

Other changed files

  • src/main/java/com/vaadin/demo/reference/componentinternals/events/ui/SearchEvent.java (added)

Built from 5370670

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants