Guides
Defining commands
Declare a @DesktopCommand method and call it from the frontend.
Add a @DesktopCommand("area.name") method to a public service class. Every command must declare a capability decision — @RequiresCapability(...) or @PublicDesktopCommand.
@DesktopCommand("greeting.greet")
@RequiresCapability("greeting:use")
public CompletionStage<GreetResponse> greet(GreetRequest req, InvocationContext ctx) {
return CompletableFuture.completedFuture(new GreetResponse("Hello, " + req.name()));
}
Handlers run on a virtual thread, off the UI thread — just block for I/O. Do not wrap work in CompletableFuture.supplyAsync.
Call it from JavaScript#
import { commands } from "./jdesk-ts/commands";
const response = await commands.greeting.greet({ name: "Ada" });