com.vaadin.flow.templatemodel.
Interface TemplateModel
-
All Superinterfaces:
Deprecated.
Template model and polymer template support is deprecated - we recommend you to useLitTemplate
instead. Read more details from the Vaadin blog.
@Deprecated public interface TemplateModel extends Serializable
Represents a template model. Extending this interface and adding getters and setters makes it possible to easily bind data to a template.
It is also possible to import a Bean's properties to the model using
importBean(String, Object, Predicate)
Supported property types:
- boolean & Boolean
- int & Integer
- double & Double
- String
- Java Bean with only properties of supported types
- List of Java Beans
Since:
1.0
Author:
Vaadin Ltd
-
-
Method Summary
All Methods Modifier and Type Method and Description default <T> List<T>
getListProxy(String modelPath, Class<T> beanType)
Deprecated.
Gets a proxy of the given part of the model as a list of beans of the given type.
default <T> T
getProxy(String modelPath, Class<T> beanType)
Deprecated.
Gets a proxy of the given part of the model as a bean of the given type.
default void
importBean(String modelPath, Object bean, Predicate<String> propertyNameFilter)
Deprecated.
Import a bean properties passing the given filter to this template model.
default void
importBeans(String modelPath, List<?> beans, Predicate<String> propertyNameFilter)
Deprecated.
Imports a list of beans to this template model.
-
-
-
Method Detail
-
getProxy
default <T> T getProxy(String modelPath, Class<T> beanType)
Deprecated.
Gets a proxy of the given part of the model as a bean of the given type. Any changes made to the returned instance are reflected back into the model.
You can use this for a type-safe way of updating a bean in the model. You should not use this to update a database entity based on updated values in the model.
The
modelPath
is a dot separated set of property names, representing the location of the bean in the model. The root of the model is "" and the path "person" represents whatgetPerson()
would return. The path "person.address" represents whatgetPerson().getAddress()
would return.public class Address { private String street; public String getStreet(){ return street; } public void setStreet(String street){ this.street = street; } } public class Person { private String name; private Address address; public String getName(){ return name; } public void setName(String name){ this.name = name; } public void setAddress(Address address){ this.address = address; } public Address getAddress(){ return address; } } interface MyModel extends TemplateModel { Person getPerson(); }
Type Parameters:
T
- the proxy typeParameters:
modelPath
- a dot separated path describing the location of the bean in the modelbeanType
- requested bean typeReturns:
a proxy instance of the bean found at the given
modelPath
-
getListProxy
default <T> List<T> getListProxy(String modelPath, Class<T> beanType)
Deprecated.
Gets a proxy of the given part of the model as a list of beans of the given type. Any changes made to the returned instance are reflected back into the model.
You can use this to update the collection or the contents of the collection in the model.
The
modelPath
is a dot separated set of property names, representing the location of the list in the model. The root of the model is "" and the path "persons" represents whatList <Person> getPersons()
would return.Type Parameters:
T
- the proxy typeParameters:
modelPath
- a dot separated path describing the location of the list in the modelbeanType
- requested bean typeReturns:
a proxy instance of the list found at the given
modelPath
-
importBean
default void importBean(String modelPath, Object bean, Predicate<String> propertyNameFilter)
Deprecated.
Import a bean properties passing the given filter to this template model.
The given filter should decide based on the bean property name whether that property should be imported to the model. For nested bean properties, the dot annotation is used.
For example, when the given
bean
is of type Person, and it has a propertyAddress address
, the properties inside theAddress
are passed to the given filter prefixed withaddress.
. e.g.address.postCode
.Parameters:
modelPath
- a dot separated path describing the location of the bean in the modelbean
- the to importpropertyNameFilter
- the filter to apply to the bean's propertiesSee Also:
-
importBeans
default void importBeans(String modelPath, List<?> beans, Predicate<String> propertyNameFilter)
Deprecated.
Imports a list of beans to this template model.
Parameters:
modelPath
- the path defining which part of the model to import intobeans
- the beans to importpropertyNameFilter
- a filter determining which bean properties to importSee Also:
importBean(String, Object, Predicate)
,supported property types
-
-