CRUD Form Editor usando Signals
- Il Caso d’Uso
- Panoramica dell’Architettura
- Passaggi di Implementazione
- Punti Chiave
- Argomenti Correlati
Questa guida mostra come creare un form editor CRUD (Create, Read, Update, Delete) reattivo che si sincronizza con una grid usando signals. L’approccio elimina catene complesse di gestione degli eventi mantenendo al contempo una funzionalità robusta.
Il Caso d’Uso
Vogliamo creare un’interfaccia in cui gli utenti possano:
-
Visualizzare elementi in una grid
-
Selezionare un elemento per la modifica
-
Vedere aggiornamenti immediati del form in base alla selezione
-
Creare nuovi elementi o aggiornare quelli esistenti
-
Salvare le modifiche con un feedback di validazione appropriato
La sfida principale è gestire in modo reattivo lo stato dell’elemento selezionato, assicurando che i componenti UI rimangano perfettamente sincronizzati senza coordinamento manuale.
Panoramica dell’Architettura
La soluzione sfrutta tre concetti fondamentali con una chiara separazione delle responsabilità:
-
Signals per la gestione reattiva dello stato (in particolare per l’elemento selezionato)
-
Binder per il binding tra form e dati e per la validazione
-
Effects per sincronizzare i dati tra la selezione della grid e il form
Passaggi di Implementazione
1. Creare la Grid degli Elementi e il Form
Per prima cosa, serve una classe di modello dati che rappresenti i nostri elementi:
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
Configurare una grid per visualizzare gli elementi e gestire la selezione:
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
Creare e collegare i campi del form usando il binder:
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
2. Sincronizzare la Selezione della Grid e il Form usando un Signal
Usare ValueSignal per tracciare l’elemento attualmente selezionato:
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
Questo signal conterrà o un elemento realmente selezionato (per la modifica) oppure uno speciale placeholder NEW_ITEM per creare nuovi elementi.
Il nuovo elemento è il valore iniziale, poiché per impostazione predefinita non è selezionato nulla.
Ora creare una sincronizzazione bidirezionale tra la selezione della grid e il signal:
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
Successivamente, aggiungere un effect per aggiornare il binder con i dati dell’elemento selezionato:
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
|
Note
|
Questo esempio usa Usare invece |
3. Creare un Pulsante di Salvataggio Dinamico
Aggiungere un signal booleano derivato per distinguere tra la creazione di un nuovo elemento e la modifica di un elemento esistente selezionato nella grid.
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
Aggiungere il pulsante di salvataggio con etichetta e comportamento reattivi a seconda che si stia modificando un elemento nuovo o esistente:
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
Combinare tutti i componenti e aggiungerli alla view:
Source code
CrudEditorExample.java
package com.vaadin.demo.flow.signals.usecase;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.combobox.ComboBox;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.notification.NotificationVariant;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.data.binder.ValidationException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.signals.Signal;
import com.vaadin.flow.signals.local.ValueSignal;
import org.jspecify.annotations.NonNull;
import java.util.List;
@Route("crud-editor-with-signals")
public class CrudEditorExample extends VerticalLayout {
static private final Item NEW_ITEM = new Item();
public CrudEditorExample() {
Grid<Item> itemGrid = new Grid<>(Item.class);
itemGrid.setColumns("product", "category");
itemGrid.setItems(listItems());
ValueSignal<Item> selectedItemSignal = new ValueSignal<>(NEW_ITEM);
// Update signal when user selects an item in the grid
itemGrid.addSelectionListener((event) -> selectedItemSignal
.set(event.getFirstSelectedItem().orElse(NEW_ITEM)));
// Keep grid selection in sync with the signal (if signal changes
// programmatically)
Signal.effect(this, () -> itemGrid.select(selectedItemSignal.get()));
add(itemGrid);
Binder<Item> itemBinder = new Binder<>();
TextField productNameField = new TextField("Product");
itemBinder.forField(productNameField).bind(Item::getProduct,
Item::setProduct);
ComboBox<String> categoryField = new ComboBox<>("Category");
categoryField.setItems(List.of("Office", "Tech", "Stationery"));
itemBinder.forField(categoryField).bind(Item::getCategory,
Item::setCategory);
Signal.effect(this,
() -> itemBinder.readBean(selectedItemSignal.get()));
// Derived signal, true when no item is selected (creating a new item)
final Signal<Boolean> creatingItemSignal = selectedItemSignal
.map(NEW_ITEM::equals);
Button saveButton = new Button(
() -> creatingItemSignal.get() ? "Create" : "Update");
saveButton.addClickListener((event) -> {
try {
// Note: the method uses `peek()` to read signals, as the click
// listener should not subscribe to the state changes.
boolean creatingItem = creatingItemSignal.peek();
// Create a new item instance or reuse existing for editing
Item item = creatingItem ? new Item()
: selectedItemSignal.peek();
// Save changes from the binder
itemBinder.writeBean(item);
item = saveItem(item);
// Update the selected item signal to use the saved item
selectedItemSignal.set(item);
// Refresh the data in the grid
itemGrid.getDataProvider().refreshAll();
// Show success notification
final String successMessage = creatingItem ? "Item added"
: "Item updated";
Notification
.show(successMessage, 3000,
Notification.Position.BOTTOM_END)
.addThemeVariants(NotificationVariant.LUMO_SUCCESS);
} catch (ValidationException e) {
// Show validation error
Notification.show("Invalid item", 3000,
Notification.Position.BOTTOM_END);
}
});
FormLayout formLayout = new FormLayout();
formLayout.setAutoResponsive(true);
formLayout.addFormRow(productNameField, categoryField, saveButton);
add(formLayout);
}
static private List<Item> listItems() {
return List.of(new Item(1, "Laptop", "Tech"),
new Item(2, "Desk Chair", "Office"),
new Item(3, "Monitor", "Tech"), new Item(4, "Keyboard", "Tech"),
new Item(5, "Mouse Pad", "Office"),
new Item(6, "Printer Paper", "Office"),
new Item(7, "Stapler", "Office"),
new Item(8, "Desk", "Stationary"),
new Item(9, "Notebook", "Office"),
new Item(10, "Pen Set", "Office"),
new Item(11, "Cable Ties", "Tech"),
new Item(12, "Extension Cord", "Tech"));
}
static private @NonNull Item saveItem(@NonNull Item item) {
// Make the item change persistent, for example, using a database
final Item savedItem = new Item();
savedItem.setId(item.getId());
savedItem.setProduct(item.getProduct());
savedItem.setCategory(item.getCategory());
return savedItem;
}
/**
* Item bean class for storing supply information
*/
static public class Item {
private long id;
@NonNull
private String product = "";
@NonNull
private String category = "";
// Constructor
public Item() {
}
// Parameterized constructor with all fields
public Item(long id, @NonNull String product,
@NonNull String category) {
this.id = id;
this.product = product;
this.category = category;
}
// Getters and Setters
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public @NonNull String getProduct() {
return product;
}
public void setProduct(@NonNull String product) {
this.product = product;
}
public @NonNull String getCategory() {
return category;
}
public void setCategory(@NonNull String category) {
this.category = category;
}
@Override
public String toString() {
return String.format("Item[id=%d, product='%s', category='%s']", id,
product, category);
}
}
}
Punti Chiave
- Usare signals per lo stato della UI
-
Il
selectedItemSignaldiventa l’unica fonte di verità per “quale elemento è in modifica”. Tutti i componenti che devono visualizzare/modificare questo elemento possono reagire ai cambiamenti di questo signal. La grid e il form rimangono perfettamente sincronizzati senza coordinamento manuale. - Aggiungere signals derivati per logica calcolata
-
Il
creatingItemSignalindica se si sta modificando un elemento nuovo (non salvato) oppure uno esistente. Questo guida comportamenti dinamici come le etichette dei pulsanti e la logica di persistenza dei dati. - Usare effects per la reattività della UI
-
Signal.effect()esegue aggiornamenti reattivi della UI in base alle dipendenze del signal. Binder::readBean(bean)eBinder::writeBean(bean)-
Usati per sincronizzare lo stato del form tra il binder e il signal dello stato del bean.
- Quando usare
Signal::peek() -
Quando serve il valore corrente ma non si vuole creare una dipendenza dal signal. Per esempio, negli handler di evento in cui serve solo lo stato corrente senza sottoscriversi ai cambiamenti.
Argomenti Correlati
-
Form Binding with Dynamic Validation - Combinare Binder con signals per form con logica di validazione dinamica
-
Local Signals - Comprendere ValueSignal e il binding bidirezionale
-
Effects and Computed Signals - Creare valori derivati
-
Component Bindings - Collegare signals alle proprietà dei componenti
-
Grid - Documentazione di riferimento per il componente Grid