Docs

Documentation versions (currently viewingVaadin 25.4 (pre-release))

Extract and Edit Component Classes

Extract part of a view into a component class of its own, and step inside a component class to change the class, not the view that uses it.

A part of a view that you want to reuse, such as a form, can become a component class of its own. Copilot extracts it, and edits inside it: the change goes into its class, and so into every view that uses it.

Extract a Component

Extract the form into a class
  1. Select the form: click a field, and press ← for its parent. In its ⋮ menu, point at Extract to Inner Component.

  2. Click it. Copilot moves the form and its fields into a class inside the view’s class, MyComponent, and selects it: its badge now has the ↳ button of a component class.

The new class is inside the view’s class. To use it in other views, move it to a file of its own with your IDE’s refactoring, such as Move in IntelliJ IDEA. Give it a name of its own, too.

Edit Inside a Component Class

Change the form’s own class
  1. Here the form is a ContactForm, a class in a file of its own. Click a field in it, and the form is selected as a whole: its badge has a ↳ button that edits ContactForm.java instead of the view.

  2. Click it, and select a field inside. The Editing tag names ContactForm.java, and everything outside the form is dimmed.

  3. Changes now go into ContactForm.java, and so into every view that has the form. Here Phone gets a helper text in Properties.

  4. Click ↰ in the Editing tag to go back up to the view’s file, ContactView.java.

Which File Copilot Changes

The Editing tag names the file that your changes go into. Outside a component class, that’s the view’s file: changing the component there changes it in that view only. Inside, it’s the component’s class, and the change shows in every view that uses the component.