What is ACE Web?

ACE Web is a set of concepts and utilities facilitating effective and efficient development of web solutions on top of ACE.

Setup

ACE Web is aquired into a project using it's Maven dependencies:

<dependency>
  <groupId>com.atex.ace.web</groupId>
  <artifactId>dispatcher</artifactId>
  <version>VERSION</version>
</dependency>

<dependency>
  <groupId>com.atex.ace.web</groupId>
  <artifactId>types</artifactId>
  <version>VERSION</version>
</dependency>

You can view the list of released versions here.

Concepts

Dispatcher

The ACE Web dispatcher is used to dispatch rendering of content paths.

Controllers

An ACE Web render controller is used to prepare the model used when rendering a content. A render controller is tied to an ACE content type.

Models

Global model

The global model contains data that will be available for rendering during the entire dispatch request, regardless of whether the currently rendered content is a result of a sub-rendering request or not.

Local model

The local model contains data local to the content currently being rendered. Any data put into the local model will be lost during potential sub-rendering of another content.

Context model

The context model contains information on the current render request, such as the site and section.

Render request

The render request contains request parameters and information for the current dispatch chain.

Usage

Declaring a controller

@Component
@TypeController(typeName = "article", contentTypeClass = Article.class)
public class SiteRenderController
    extends SectionRenderController
{
    @Override
    public String dispatch(final Content<WebSectionBean> content,
                           final LocalModel model,
                           final ContextModel contextModel,
                           final RenderRequest requestParameters)
        throws RenderControllerException
    {
        // Prepare the model for rendering, and perform any needed pre-rendering work...

        return "article";
    }
}

Rendering a content path

...

@Autowired private WebDispatcher webDispatcher;
@Autowired private PathTranslator pathTranslator;

...

@RequestMapping(...)
public String dispatch(final HttpServletRequest request,
                       final HttpServletResponse response,
                       final Model model)
    throws SpaceDispatchException
{
    List<String> friendlyAliasPath = Arrays.asList("segment1", "segment2");

    try {
        List<Alias> aliases = pathTranslator.translatePath(friendlyAliasPath);
        return webDispatcher.dispatch(aliases, model, Collections.emptyMap(), request, response);
    } catch (WebException e) {
        // Handle error...
    }
}

...

Sub-rendering another content

<th:block th:text="${site.id}"></th:block>