Fórum

[Solved] Trying to add a new Struts action for Blog

thumbnail
Juanjo Hernández Cánovas, modificado 10 Anos atrás.

[Solved] Trying to add a new Struts action for Blog

Regular Member Postagens: 183 Data de Entrada: 11/08/08 Postagens Recentes
Hello,

I'm trying to add a new Struts Action for the Blog. I have made a hook for this new behaviour following the "how to" http://www.liferay.com/es/web/mika.koivisto/blog/-/blogs/overriding-and-adding-struts-actions-from-hook-plugins. All seems to works ok, but when I call the new action from a jsp I get this exception:


ERROR [http-bio-8080-exec-126][status_jsp:665] java.lang.ClassCastException: com.liferay.portal.struts.ActionAdapter cannot be cast to com.liferay.portal.struts.PortletActionAdapter
java.lang.ClassCastException: com.liferay.portal.struts.ActionAdapter cannot be cast to com.liferay.portal.struts.PortletActionAdapter


The hook's code is:

liferay-hook.xml
<hook>
    <custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
      
    <struts-action>
    	<struts-action-path>/blogs/share_notificacion</struts-action-path>
    	<struts-action-impl>
    		com.pymoo.hook.blogs.action.ShareNotificacionAction
    	</struts-action-impl>
    </struts-action>
    
</hook>


ShareNotificacionAction Action class
public class ShareNotificacionAction extends BaseStrutsAction {
	private static final Log log = LogFactory.getLog(ShareNotificacionAction.class);
	public String execute(HttpServletRequest request, HttpServletResponse response) 
			throws Exception {
		log.info("Inside Share notificacion Action");
		return "/portal/sample.jsp"; 
	}
}


The hooked jsp view_entry_content.jsp
&lt;%@include file="/html/portlet/blogs/init.jsp" %&gt;

<liferay-util:buffer var="html">
	<liferay-util:include page="/html/portlet/blogs/view_entry_content.portal.jsp" useCustomPage="<%= false %>" />
</liferay-util:buffer>

&lt;%= html %&gt;

<portlet:actionurl var="shareNotificacionURL">
	<portlet:param name="struts_action" value="/blogs/share_notificacion" />
</portlet:actionurl>

<div id="<portlet:namespace />share_notificacion">
	<aui:a cssClass="share" href="<%= shareNotificacionURL %>" label="share" />
</div>


I have seen the forum entry https://www.liferay.com/es/community/forums/-/message_boards/message/13487363, but this solution doesn't work for me.

Thanks in advanced for your help.

Greetz,

Juanjo.
thumbnail
Mika Koivisto, modificado 10 Anos atrás.

RE: Trying to add a new Struts action for Blog

Liferay Legend Postagens: 1519 Data de Entrada: 07/08/06 Postagens Recentes
You are extending wrong class. When dealing with portlet struts action you need to extend BaseStrutsPortletAction instead of BaseStrutsAction which is used for paths under /c
thumbnail
Juanjo Hernández Cánovas, modificado 10 Anos atrás.

RE: Trying to add a new Struts action for Blog

Regular Member Postagens: 183 Data de Entrada: 11/08/08 Postagens Recentes
Hello Mika,

Thank you for your response. I tried this solution before withour good results, but it works just making a forced deploy of the hook. It doesn't works with the autodeploy on liferay sdk.

Thank you very much!

Juanjo
thumbnail
Juanjo Hernández Cánovas, modificado 10 Anos atrás.

RE: Trying to add a new Struts action for Blog

Regular Member Postagens: 183 Data de Entrada: 11/08/08 Postagens Recentes
Hi Mika,

Now I'm facing a "Forward does not exist" error. Could you guide me?

Thanks in advanced,

Juanjo.
thumbnail
Juanjo Hernández Cánovas, modificado 10 Anos atrás.

RE: Trying to add a new Struts action for Blog

Regular Member Postagens: 183 Data de Entrada: 11/08/08 Postagens Recentes
Hi one more time :-)

Digging on forum and wiki I have modified the render function to:

return originalStrutsPortletAction.render( originalStrutsPortletAction, portletConfig, renderRequest, renderResponse);


And now the error is

10:43:42,257 ERROR [http-bio-8080-exec-90][render_portlet_jsp:154] java.lang.NullPointerException


with the same result.

Any tip or advice?

Thanks in advanced,

Juanjo.
Roman Pelegin, modificado 9 Anos atrás.

RE: Trying to add a new Struts action for Blog

New Member Postagens: 6 Data de Entrada: 17/02/14 Postagens Recentes
Hello Juanjo!
Did you solved this problem?
I faced with the same thing and I have no idea what the problem. emoticon