Are there any web frameworks for JVM with data binding checked at compilation time?

ⅰ亾dé卋堺 提交于 2019-12-01 05:37:27

问题


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).


回答1:


JSP development in Eclipse can do this




回答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.




回答3:


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



来源:https://stackoverflow.com/questions/9620802/are-there-any-web-frameworks-for-jvm-with-data-binding-checked-at-compilation-ti

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!