Information about and operations for classes generated by the
Can be used in classes annotated with
Methods in class annotated by
Defines a model class that represents a single JSON-like object named
The threading model of classes generated by
Marks a method that is going to be notified when a property defined by
Represents a property in a class defined with
This API allows you to write your application logic in Java and present it using modern HTML rendering technologies like Knockout and communicate with a server via REST or WebSockets.
Use @Model annotation to define one or more model classes with properties. Don't waste time writing setters or getters - they will be generated for you. Just instantiate your classes and use them!
The class generator does not stop with getters and setters -- internally
it generates bindings for various HTML technologies. Just include appropriate
technology implementation on classpath of your application and your model
class(es) will automatically be bound to your HTML elements (after calling
applyBindings() on your model).
as an implementation detail of communication between the generated model
class(es) and appropriate technology bridge. For example
<dependency> <groupId>org.netbeans.html</groupId> <artifactId>ko4j</artifactId> <scope>runtime</scope> </dependency>
In case you decide to use Knockout
as your rendering technology, it is recommended to look at its
(especially its HTML part) as
data-bind syntax is exactly
what one has to use in the HTML file(s). Of course, one does not need
code generated when processing the
The model classes can be used for JSON based server communication. Just use @OnReceive annotation to define a communication point in the model class. Please note, that the model classes can easily be used on server as well - the same code can run in your client as well as on your server. Just add following to your pom.xml to use your classes generated by @Model annotation as Jersey entities:
<dependency> <groupId>org.glassfish.jersey.media</groupId> <artifactId>html-json</artifactId> <version>2.6</version> <scope>runtime</scope> </dependency>
Behavior of model classes can be enriched by using @ComputedProperty annotation (to define derived properties) and by @Function annotation to define handlers to be invoked from the HTML elements.
Copyright © 2021 The Apache Software Foundation. All rights reserved.