HttpAction

HttpAction handles a conventional HTTP request and returns a Component to render as the response. It is a natural entry point for pages and server-generated views.

Overview

The application HttpController selects an action using its mapper. The action receives HttpContext and returns a Component; unlike AjaxAction, it does not send UI PushActions as its primary result.

The button navigates to a real HttpAction that renders a short response with a request parameter.

CODE
Button button = new Button("Open HTTP action");
button.onClick(new HttpActionOverview()
        .addParameter("name","JDance"));
RESULT

Parameters example

This variation passes a different parameter value to the action. It demonstrates that action instances can carry URL parameters.

CODE
Button button = new Button("Open parameter example");
button.onClick(new HttpActionParameters()
        .addParameter("name","Documentation"));
RESULT

How it works

CODE
public class HttpActionOverview extends HttpAction{
    @Override
    public void init(){
        setActionMapper(HttpControl.instance.getActionMapper());
    }

    @Override
    public Component perform(HttpContext context) throws Exception{
        String name = context.getRequest().getParameter("name");
        return new Text("Hello " + name);
    }
}

HTTP request parameters

Use a request parameter to control the response. An HttpAction returns a Component rather than a PushAction.

CODE
String name = context.getRequest().getParameter("name");
return new Text("Hello " + name);

Design guidance

Use HttpAction for navigation and full HTTP responses. Use AjaxAction for in-place updates. Larger pages can return a dedicated Page component instead of constructing everything in perform().

Full API reference

These examples introduce the most important behavior without attempting to document every method. For the complete reference, see https://doc.jdance.org.