Directory

← Back

CDI Properties

Define Vaadin component properties with annotations

Author

Contributors

Rating

CDI Properties contains individual annotations for each Vaadin core component that allow you to define a set of properties right above the injection point.

...so instead of:

TextField textField = new TextField("Name"); textField.setMaxLength(15); textField.setNullRepresentation(""); textField.setWidth("100%");

..you can:

@Inject @TextFieldProperties(caption = "Name", maxLength = 15, nullRepresentation = "", width = "100%") private TextField textField;

Use properties "captionKey" and "labelValueKey" to assign text values provided by your own TextBundle bean. Fire a @TextBundleUpdated event to utilize the built-in i18n functionality allowing you to change your applications language run-time.

The add-on can only be used in Vaadin CDI enabled projects.

Sample code

@UIScoped
public class SearchViewImpl extends AbstractView implements SearchView {

    @Inject
    @TextFieldProperties(captionKey = "searchview-searchterm", nullRepresentation = "")
    private TextField searchTerm;
    @Inject
    @NativeSelectProperties(captionKey = "searchview-fieldtosearch")
    private NativeSelect fieldToSearch;
    @Inject
    @CheckBoxProperties(captionKey = "searchview-savesearch", immediate = true)
    private CheckBox saveSearch;
    @Inject
    @TextFieldProperties(captionKey = "searchview-searchname", nullRepresentation = "")
    private TextField searchName;
    @Inject
    @PanelProperties(captionKey = "searchview-caption")
    private Panel mainPanel;
    @Inject
    @ButtonProperties(captionKey = "searchview-search")
    private Button searchButton;

...

}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Vaadin 8 support (thanks to https://github.com/klenkes74)

Released
2017-03-26
Maturity
BETA
License
Apache License 2.0

Compatibility

Framework
Vaadin 8.0+
Vaadin 7.0+ in 0.9.3
Browser
Browser Independent

CDI Properties - Vaadin Add-on Directory

Define Vaadin component properties with annotations CDI Properties - Vaadin Add-on Directory
CDI Properties contains individual annotations for each Vaadin core component that allow you to define a set of properties right above the injection point. ...so instead of: TextField textField = new TextField("Name"); textField.setMaxLength(15); textField.setNullRepresentation(""); textField.setWidth("100%"); ..you can: @Inject @TextFieldProperties(caption = "Name", maxLength = 15, nullRepresentation = "", width = "100%") private TextField textField; Use properties "captionKey" and "labelValueKey" to assign text values provided by your own TextBundle bean. Fire a @TextBundleUpdated event to utilize the built-in i18n functionality allowing you to change your applications language run-time. The add-on can only be used in Vaadin CDI enabled projects.
Online