Beans and lists in template model
Pre-release
Pre-release
New features
- Support for beans in template model
public interface FormModel extends TemplateModel {
public void setPerson(Person person);
public Person getPerson();
}
- Getter for a bean returns a proxy object which is connected to the model (setters update the model values)
- Setter for a bean copies the bean values into the model
- Low level model API for handling beans in the model:
void TemplateModel.importBean(Object bean)
void TemplateModel.importBean(Object bean, Predicate<String> propertyNameFilter)
T TemplateModel.getProxy(String modelPath, Class<T> beanType)
- Support for setting lists of beans in the model
public interface EmployeesModel extends TemplateModel {
public void setEmployees(List<Employee> employees);
}
- Support for setting attributes on template elements from Java
- Support for binding to attributes in templates using
[attr.placeholder]="modelPart"
- Shorthand for setting boolean attributes:
Element.setAttribute(String, boolean)
- Shorthand for clearing an Input value:
Input.clear()
- All builds are automatically scalability tested using Gatling
Fixes
- Use of the
@Id
annotation has been clarified in some tutorials
Demos
Tutorials
- Using Beans with a Template Model
- Including Templates in Templates
- Creating Template Contents Dynamically Based on a List of Items (Using a list in a template model)