loading table of contents...

Content Application Developer Manual / Version 2310

Table Of Contents Post Processing Links

Similar to handler interceptors, it is also possible to post process generated links. A common use case is to prepend a prefix (such as context and servlet path) to the URI when the link schemes are used to generate the link suffixes only.

package com.mycompany;
import com.coremedia.objectserver.view.ViewUtils;
import org.springframework.web.util.UriComponentsBuilder;
import org.springframework.web.util.UriComponents;
import com.coremedia.objectserver.web.links.UriComponentsHelper;
public class MyLinkPostProcessor {
  public UriComponentsBuilder prependPrefix(UriComponents originalUri,
                                            HttpServletRequest request) {

    String baseUri = ViewUtils.getBaseUri(request);
    return UriComponentsHelper.prependPath(baseUri, originalUri);
<beans xmlns="">
  <import resource="classpath:/com/coremedia/cae/link-services.xml"/>
  <bean id="myLinkPostProcessor"

This example demonstrates how the base URI (context path and the servlet path) is prepended to an URI that has been built by an annotated link scheme. Writing a post processor is quite similar to writing a link scheme. The main difference is that the original link needs to be passed to the post processor method as a parameter of type UriComponents or UriComponentsBuilder. All other parameters bindings as well as the possible return types are the same. Just like the @Link annotation, the @LinkPostProcessor supports an optional type element which restricts the post-processor to links for the particular bean types.

Search Results

Table Of Contents

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.