Create reactive web apps with serverside Java.
@DeriveElement
public record Counter() implements Component<Props> {
public record Props() {}
@Override
public JadeElement component(Props props) {
final var state = useState(0);
final FormAction increment = _ -> {
state.set(state.value() + 1);
};
return Div(
Form(javaaction(increment),
Button(type("submit"),
Text("Count is " + state.value())
)
)
);
}
}
Decompose your UI into components. Use hooks to declare state and effects. Use the Element DSL to create your view. Use props to parameterize your components.
DSL for the standard HTML elements and attributes is built in. An annotation processor generates DSL for your components.
When a new window is opened, Jade renders it serverside and sends down exactly the HTML you'd expect. Actions are received using native forms, and navigation is performed using native anchors.
A thin JavaScript runtime is included in the rendered HTML. If the client supports JavaScript, an SSE connection is established. While open, actions will be executed over fetch, view-changes will be received over SSE, and the window will be updated in-place.
Realtime applications register effects which proactively update the component tree. These updates become visible to enhanced clients immediately, no user-interaction required. Primitives are provided for reacting logically to the capability of the connected client.
Java is easy to read, but can be verbose to write. The jade command line tool can setup up a new component class for you instantly.
The Jade project's source code is available under the Apache license (v2).
Clone the git repo to get the source code.
git clone https://jadeframework.net/git/jadeframework