3

Usually when you bind some property to some element in www page, you will know about typo when testing.

I am looking for web framework which, at compile time would give me an error, that I made error in binding ("property not found" or something similar) and assuming my IDE has valid refactorization mechanism, that renaming property would also affect the binding (and vice-versa), or in other words, that renaming would not result in broken code.

Is there such framework for JVM?

I am new to JVM world so I don't know the features of the JVM frameworks (at all, not just this feature I ask for).

greenoldman
  • 16,895
  • 26
  • 119
  • 185

3 Answers3

2

I've implemented static-mustache library to provide a type-safe template engine based on mustache syntax.

It checks both syntax errors and type-errors (like missing property) at compile-time. It requires zero build configuration as it's a standard annotation processor.

Templates remain pure mustache templates with all type-information extracted from normal Java-class used for rendering.

Victor Nazarov
  • 825
  • 8
  • 11
1

Vaadin Framework

Vaadin 8+ supports this kind of binding with Java lambda expressions.

There is a special Binder class:

Binder<Person> binder = new Binder<>();
TextField titleField = new TextField();

// Start by defining the Field instance to use
binder.forField(titleField)
  // Finalize by doing the actual binding to the Person class
  .bind(
    // Callback that loads the title from a person instance
    Person::getTitle,
    // Callback that saves the title in a person instance
    Person::setTitle));

See docs for details: https://vaadin.com/docs/framework/datamodel/datamodel-forms.html

jreznot
  • 2,694
  • 2
  • 35
  • 53
1

JSP development in Eclipse can do this

Roy Truelove
  • 22,016
  • 18
  • 111
  • 153
  • [*Vaadin Framework*](http://www.Vaadin.com/) is so much easier and more productive, with a sophisticated yet easy-to-use data binding facility and integrated Bean Validation support. See [the Answer by jreznot](https://stackoverflow.com/a/48167110/642706). – Basil Bourque Jan 11 '18 at 05:40