All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vaadin.annotations.PropertyId Maven / Gradle / Ivy

There is a newer version: 8.27.3
Show newest version
/*
 * Copyright (C) 2000-2024 Vaadin Ltd
 *
 * This program is available under Vaadin Commercial License and Service Terms.
 *
 * See  for the full
 * license.
 */
package com.vaadin.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import com.vaadin.data.Binder;
import com.vaadin.data.HasValue;

/**
 * Defines the custom property name to be bound to a {@link HasValue field
 * component} using {@link Binder}.
 * 

* The automatic data binding in Binder relies on a naming convention by * default: properties of an item are bound to similarly named field components * in given a editor object. If you want to map a property with a different name * (ID) to a {@link HasValue}, you can use this annotation for the member * fields, with the name (ID) of the desired property as the parameter. *

* In following usage example, the text field would be bound to property "foo" * in the Entity class. * *

 * class Editor extends FormLayout {
 *     @PropertyId("foo")
 *     TextField myField = new TextField();
 * }
 *
 * class Entity {
 *     String foo;
 * }
 *
 * {
 *     Editor editor = new Editor();
 *     Binder<Entity> binder = new Binder(Entity.class);
 *     binder.bindInstanceFields(editor);
 * }
 * 
* * @since 8.0 * @author Vaadin Ltd */ @Target({ ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) public @interface PropertyId { String value(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy