Interface TemplateModel

  • All Superinterfaces:
    Serializable

    @Deprecated
    public interface TemplateModel
    extends Serializable
    Deprecated.
    Template model and polymer template support is deprecated - we recommend you to use LitTemplate instead. Read more details from the Vaadin blog.
    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 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 what getPerson() would return. The path "person.address" represents what getPerson().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 type
        Parameters:
        modelPath - a dot separated path describing the location of the bean in the model
        beanType - requested bean type
        Returns:
        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 what List <Person> getPersons() would return.

        Type Parameters:
        T - the proxy type
        Parameters:
        modelPath - a dot separated path describing the location of the list in the model
        beanType - requested bean type
        Returns:
        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 property Address address, the properties inside the Address are passed to the given filter prefixed with address.. e.g. address.postCode.

        Parameters:
        modelPath - a dot separated path describing the location of the bean in the model
        bean - the to import
        propertyNameFilter - the filter to apply to the bean's properties
        See Also:
        supported property types
      • 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 into
        beans - the beans to import
        propertyNameFilter - a filter determining which bean properties to import
        See Also:
        importBean(String, Object, Predicate), supported property types