Skip to main content
Tweeted twitter.com/StackTridion/status/951621813393555457
mention DXA documentation
Source Link
Jan H
  • 8.8k
  • 1
  • 22
  • 42

I want to customize the page controller in a DXA JAVA implementation. How can we doIs that possible, and how?

I tried to extend the DXA PageController, but of course that does not work

@Controller
public class MyPageController extends PageController {

    @RequestMapping(
            value = {"/jan"},
            params = {"test"},
            produces = {"text/html", "*/*"}
    )
    @Override
    public String handleGetPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // do your stuff
        return super.handleGetPage(request, response);
    }
}

The problem is that in Spring there is no way to override the @RequestMapping, and each mapping has to be unique.

@bearddev had a similar question for DXA .NET. The .NET answer does not apply to DXA JAVA as routing is not configured in a single place in DXA JAVA.

The DXA documentation mentions how to "Create a controller class", but that only applies to region and entity controllers.

I want to customize the page controller in a DXA JAVA implementation. How can we do that?

I tried to extend the DXA PageController, but of course that does not work

@Controller
public class MyPageController extends PageController {

    @RequestMapping(
            value = {"/jan"},
            params = {"test"},
            produces = {"text/html", "*/*"}
    )
    @Override
    public String handleGetPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // do your stuff
        return super.handleGetPage(request, response);
    }
}

The problem is that in Spring there is no way to override the @RequestMapping, and each mapping has to be unique.

@bearddev had a similar question for DXA .NET. The .NET answer does not apply to DXA JAVA as routing is not configured in a single place in DXA JAVA.

I want to customize the page controller in a DXA JAVA implementation. Is that possible, and how?

I tried to extend the DXA PageController, but of course that does not work

@Controller
public class MyPageController extends PageController {

    @RequestMapping(
            value = {"/jan"},
            params = {"test"},
            produces = {"text/html", "*/*"}
    )
    @Override
    public String handleGetPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // do your stuff
        return super.handleGetPage(request, response);
    }
}

The problem is that in Spring there is no way to override the @RequestMapping, and each mapping has to be unique.

@bearddev had a similar question for DXA .NET. The .NET answer does not apply to DXA JAVA as routing is not configured in a single place in DXA JAVA.

The DXA documentation mentions how to "Create a controller class", but that only applies to region and entity controllers.

Source Link
Jan H
  • 8.8k
  • 1
  • 22
  • 42

DXA JAVA Custom controller for PageModel

I want to customize the page controller in a DXA JAVA implementation. How can we do that?

I tried to extend the DXA PageController, but of course that does not work

@Controller
public class MyPageController extends PageController {

    @RequestMapping(
            value = {"/jan"},
            params = {"test"},
            produces = {"text/html", "*/*"}
    )
    @Override
    public String handleGetPage(HttpServletRequest request, HttpServletResponse response) throws Exception {
        // do your stuff
        return super.handleGetPage(request, response);
    }
}

The problem is that in Spring there is no way to override the @RequestMapping, and each mapping has to be unique.

@bearddev had a similar question for DXA .NET. The .NET answer does not apply to DXA JAVA as routing is not configured in a single place in DXA JAVA.