Upgrading /journal/edit_article struts action

Jamie Sammons, modified 4 Years ago. New Member Posts: 3 Join Date: 11/5/20 Recent Posts

Hi people,

I need to migrate from 6.2 to 7.2 dxp Liferay portal version. I cannot create a new fragment module or a other modules.

Into liferay-hook.xml file is defined this struts action

	<struts-action>
		<struts-action-path>/journal/edit_article</struts-action-path>
		<struts-action-impl>me.hook.action.CustomEditArticleAction</struts-action-impl>
	</struts-action>

And this is the CustomEditArticleAction class:

public class CustomEditArticleAction extends BaseStrutsPortletAction {
    ...
	@Override
	public String render(StrutsPortletAction originalStrutsPortletAction, 
	        PortletConfig portletConfig,
			RenderRequest renderRequest,
			RenderResponse renderResponse) throws Exception {
        logger.info("RENDER");
        ...
    }

    @Override
	public void processAction(
			StrutsPortletAction originalStrutsPortletAction,
			PortletConfig portletConfig, ActionRequest actionRequest,
			ActionResponse actionResponse)
		throws Exception {
        logger.info("PROCESS ACTION");
        ...
    }

    	@Override
	public void serveResource(
			StrutsPortletAction originalStrutsPortletAction,
			PortletConfig portletConfig, ResourceRequest resourceRequest,
			ResourceResponse resourceResponse)
		throws Exception {
        logger.info("SERVE RESOURCE");
        ...
    }
}

I'm able to build and successfully deploy generated WAR, but if I go to edit a web content nothing happens.

I read this article https://help.liferay.com/hc/en-us/articles/360029005292-Upgrading-Struts-Action-Hooks, so I create a new package, me.hook.action.mvccommands, and I started to implements the MVCRenderCommand in order to hook the render method.

This is the new class

package me.hook.action.mvccommands;
@Component(
	    immediate = true,
	    property = {
	        "javax.portlet.name=" + JournalPortletKeys.JOURNAL,
	        "mvc.command.name=/journal/update_article",
	        "service.ranking:Integer=100"
	    },
	    service = MVCRenderCommand.class
	)
public class CustomEditArticleMVCRenderCommand implements MVCRenderCommand {
	@Override
	public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException {
		
		logger.info("RENDER");
        ...
    }
}

but, unfortunately, even in this case nothing happens.

I tried to set inside the liferay-plugin-package.properties the following props

Bundle-Name: Edit Article Hook
Bundle-SymbolicName: me.hook.action.mvccommands
Bundle-Version: 1.0.0

with no results.

What am I missing?

Can you help me?

 

Thank you

 

thumbnail
Olaf Kock, modified 4 Years ago. Liferay Legend Posts: 6441 Join Date: 9/23/08 Recent Posts

As you're migrating, you'll have to validate:

  • Is this still implemented in struts? Because more and more struts-implementations are removed, to retire struts once and for all
  • If it's implemented with MVCPortlet, it'll be an ActionCommand rather than a RenderCommand. Look at how JournalPortletKeys.JOURNAL is currently implemented and carry on from there. Odds are that the actionCommand redirects to some other view that doesn't carry the original  mvc.command.name any more - or that "rendering" doesn't look at a "command" anyway.
Vincenzo Malagrinò, modified 4 Years ago. New Member Posts: 3 Join Date: 11/5/20 Recent Posts

Hi Olaf,
I think it's no more implemented in struts.
I reported the renderCommand as an example, but the problem is concerning also the actionCommand.
Actually the problem is not concerning only the Journal portlet, but all other portlets (I tried even with login portlet).
The problem is that deploying as WAB make the hook no working.

Thanks