Skip to content

Commit 9b3ce16

Browse files
peholmstclaude
andcommitted
Merge branch 'main' into flow-application-docs-restructure
Resolve conflict by keeping state.adoc deleted as intended by this branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2 parents b66486c + 2f17619 commit 9b3ce16

File tree

21 files changed

+469
-329
lines changed

21 files changed

+469
-329
lines changed

articles/building-apps/server-push/callbacks.adoc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
title: Callbacks
33
page-title: How to use server push with callbacks | Vaadin
44
description: How to use server push with callbacks.
5-
meta-description: Learn how to use server push with callbacks when building the UI layer of your Vaadin application.
5+
meta-description: Learn how to use server push with callbacks when building the UI layer of your Vaadin application.
66
order: 20
7-
section-nav: badge-flow
87
---
98

109

11-
= Implementing Callbacks [badge-flow]#Flow#
10+
= Implementing Callbacks
1211

1312
When building the user interface with Vaadin Flow, the easiest way of allowing a background job to update the user interface is through callbacks. This is explained in more detail in the <</building-apps/business-logic/background-jobs/interaction/callbacks#,Callbacks>> documentation page.
1413

15-
Whenever you implement a callback, you have remember that the callback is called by the background thread. This means that any updates to the user interface must happen inside a call to `UI.access()`.
14+
Whenever you implement a callback, remember that the callback is called by the background thread. This means that any updates to the user interface must happen inside a call to `UI.access()`.
1615

1716
[NOTE]
18-
The examples on this page only work with push enabled. For information about how to do that, see the <<.#enabling-push-flow,Server Push>> documentation page.
17+
The examples on this page only work with push enabled. For information about how to do that, see the <<index.adoc#,Server Push>> documentation page.
1918

2019
For every callback, you should create a private method in your user interface. The method is called inside `UI.access()`, so you can safely update the user interface inside it.
2120

articles/building-apps/server-push/futures.adoc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
---
22
title: Futures
3-
page-title: How to use server push with CompletableFuture | Vaadin
3+
page-title: How to use server push with CompletableFuture | Vaadin
44
description: How to use server push with CompletableFuture.
55
meta-description: Learn how to use server push with CompletableFuture when building the UI layer of your Vaadin application.
66
order: 30
7-
section-nav: badge-flow
87
---
98

109

11-
= Consuming Futures [badge-flow]#Flow#
10+
= Consuming Futures
1211

1312
Some background jobs may use `CompletableFuture` to inform the user interface of results and errors. This is covered in the <</building-apps/business-logic/background-jobs/interaction/futures#,Returning Futures>> documentation page.
1413

@@ -24,7 +23,7 @@ private void onJobCompleted(String result) {
2423
----
2524

2625
[NOTE]
27-
The examples on this page only work with push enabled (see <<.#enabling-push-flow,Server Push>>).
26+
The examples on this page only work with push enabled (see <<index.adoc#,Server Push>>).
2827

2928
A method for handling errors might look like this:
3029

articles/building-apps/server-push/index.adoc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ In Hilla views, push is always enabled when you subscribe to a _reactive endpoin
1919
Server push is not the same as Web Push, which is also supported by Vaadin Flow. For more information, see the <<{articles}/flow/configuration/webpush#,Web Push Notifications>> documentation page.
2020

2121

22-
== Enabling Push [badge-flow]#Flow#
22+
== Enabling Push
2323

2424
Before you can use server push in Flow, you have to enable it. You do this by adding the `@Push` annotation to the application shell class, like this:
2525

@@ -40,9 +40,23 @@ public class Application implements AppShellConfigurator {
4040
}
4141
----
4242

43-
// TODO Add link to page about the application shell, once is has been written (currently, the contents is scattered all over the documentation)
4443

45-
// TODO Transport modes? Or is that something for the reference material.
44+
== Push Modes
45+
46+
By default, Flow uses automatic pushing (`PushMode.AUTOMATIC`). This means that any pending changes are pushed to the browser after `UI.access()` finishes. This is the recommended mode for most applications.
47+
48+
You can also configure Flow to use manual pushing (`PushMode.MANUAL`). With manual mode, you call `UI.push()` explicitly to send changes to the browser. This gives you more control over when changes are pushed, which is useful when you want to batch multiple updates together.
49+
50+
For details on how to use `UI.access()` and `UI.push()`, see <<updates#,Pushing UI Updates>>.
51+
52+
53+
== Transport Options
54+
55+
Server push can use several transports: WebSockets, long polling, or combined WebSockets+XHR. The default is WebSockets+XHR, which works well in most environments.
56+
57+
You might need to change the transport if you're experiencing connectivity issues, for example when running behind certain proxies or corporate firewalls that block WebSocket connections. In such cases, long polling can be a more reliable alternative.
58+
59+
For technical details about configuring transports, see <<{articles}/flow/advanced/server-push#,Server Push Configuration>>.
4660

4761

4862
== Topics

articles/building-apps/server-push/reactive.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ order: 40
99

1010
When building the user interface with either Vaadin Flow or Hilla, you can use reactive streams to allow a background job to update the user interface. This is covered in the <</building-apps/business-logic/background-jobs/interaction/reactive#,Producing Reactive Streams>> documentation page.
1111

12-
//RUSSELL: This opening paragraph gives the feeling that the reader shouldn't read this page since it immediately sends them elsewhere. You need a sentence or two that says the point of continuing, maybe something about subscribing, handling errors, etc.
12+
This page covers subscribing to reactive streams, handling errors, and buffering high-frequency updates.
1313

1414

1515
== Types of Subscriptions

articles/building-apps/server-push/threads.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ page-title: How to use threads in a Vaadin Flow user interface
44
description: How to use threads in a Vaadin Flow user interface.
55
meta-description: Learn how to use use virtual threads in a Vaadin Flow user interface by reading this guide.
66
order: 10
7-
section-nav: badge-flow
87
---
98

109

11-
= User Interface Threads [badge-flow]#Flow#
10+
= User Interface Threads
1211

1312
Developers often use server push to update the user interface from background jobs (see <</building-apps/business-logic/background-jobs/interaction#,Background Jobs - UI Interaction>>). However, in Vaadin Flow, there are also cases where you may want to start a separate thread for use by the user interface itself. You might, for instance, want to show the server date and time in "real time".
1413

@@ -17,7 +16,7 @@ If you have experience with Swing, you might be tempted to use a `Timer`, or to
1716
As a better strategy, use virtual threads, or Spring's `TaskExecutor` and `TaskScheduler`. These are explained in the following sections, with some examples.
1817

1918
[NOTE]
20-
The examples on this page only work with push enabled. For information about how to do that, see the <<.#enabling-push-flow,Server Push>> documentation page.
19+
The examples on this page only work with push enabled. For information about how to do that, see the <<index.adoc#,Server Push>> documentation page.
2120

2221

2322
== Virtual Threads

articles/building-apps/server-push/updates.adoc

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ page-title: How to push updates to a Vaadin Flow user interface
44
description: How to push updates to a Vaadin Flow user interface.
55
meta-description: Learn how to push updates to a Vaadin Flow user interface by reading this guide.
66
order: 1
7-
section-nav: badge-flow
87
---
98

109

11-
= Pushing UI Updates [badge-flow]#Flow#
10+
= Pushing UI Updates
1211

1312
Whenever you're using server push in Vaadin Flow, you're triggering it from a thread other than the normal HTTP request thread. Making changes to a UI from another thread and pushing them to the browser requires locking the user session. Otherwise, the UI update performed from another thread could conflict with a regular event-driven update and cause either data corruption, race conditions or deadlocks.
1413

@@ -22,7 +21,7 @@ ui.access(() -> {
2221
----
2322

2423
[NOTE]
25-
The examples on this page only work with push enabled. For information about how to do that, see the <<.#enabling-push-flow,Server Push>> documentation page.
24+
The examples on this page only work with push enabled. For information about how to do that, see the <<index.adoc#,Server Push>> documentation page.
2625

2726
By default, Flow uses automatic pushing. This means that any pending changes are pushed to the browser after the command passed to `UI.access()` finishes. You can also configure Flow to use manual pushing. This would give you more control over when changes are pushed to the browser. For example, you can push multiple times inside a single call to `UI.access()`.
2827

@@ -49,8 +48,6 @@ ui.access(() -> {
4948

5049
== Getting the UI Instance
5150

52-
// This assumes that the UI has been explained earlier, and what attach and detach means.
53-
5451
Before you can call `access()`, you need to get the `UI` instance. You'd typically use `Component.getUI()` or `UI.getCurrent()` for this. However, both are problematic when it comes to server push.
5552

5653
`Component.getUI()` is not thread-safe, which means you should only call it while the user session is locked. Therefore, you can't use it to call `access()`.
@@ -200,5 +197,3 @@ if (ui.getSession().hasLock()) {
200197
});
201198
}
202199
----
203-
204-
// TODO Consider showing an example of a UIRunner that takes a Runnable or Consumer, performs the check, and calls it directly or inside UI.access().

0 commit comments

Comments
 (0)