Overriding MVCActionCommands

In case you want add to a Liferay MVC action command, you can. The OSGi framework lets you override MVC action commands if you follow the instructions for adding logic to MVC commands. It involves registering your custom MVC action command as an OSGi component with the same properties as the original, but with a higher service ranking.

Custom MVC action commands typically extend the BaseMVCActionCommand class, and override its doProcessAction method, which returns void. Add your logic to the original behavior of the action method by getting a reference to the original service, and calling it after your own logic.

For example, this MVCActionCommand override checks whether the delete action is invoked on a blog entry, and prints a message to the log, before continuing with the original processing:

    property = { 
        "javax.portlet.name=" + BlogsPortletKeys.BLOGS_ADMIN, 
    service = MVCActionCommand.class
public class CustomBlogsMVCActionCommand extends BaseMVCActionCommand {

    protected void doProcessAction
        (ActionRequest actionRequest, ActionResponse actionResponse) 
        throws Exception {

        String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

        if (cmd.equals(Constants.DELETE)) {
            System.out.println("Deleting a Blog Entry");

        mvcActionCommand.processAction(actionRequest, actionResponse);

        target = "(component.name=com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand)")
    protected MVCActionCommand mvcActionCommand;


Adding MVC action command logic before existing logic is straightforward and maintains loose coupling between new and old code.

« Overriding MVCRenderCommandsOverriding MVCResourceCommands »
Was this article helpful?
0 out of 0 found this helpful