Foros de discusión
Trying to add a new Struts action for Blog
Juanjo Hernández Cánovas, modificado hace 10 años.
Trying to add a new Struts action for Blog
Regular Member Mensajes: 183 Fecha de incorporación: 11/08/08 Mensajes recientes
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:
The hook's code is:
liferay-hook.xml
ShareNotificacionAction Action class
The hooked jsp view_entry_content.jsp
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.
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
<%@include file="/html/portlet/blogs/init.jsp" %>
<liferay-util:buffer var="html">
<liferay-util:include page="/html/portlet/blogs/view_entry_content.portal.jsp" useCustomPage="<%= false %>" />
</liferay-util:buffer>
<%= html %>
<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.
Brian Russell, modificado hace 9 años.
RE: Trying to add a new Struts action for Blog
Junior Member Mensajes: 41 Fecha de incorporación: 31/10/11 Mensajes recientes
Were you able to resolve your issue?
I am not having the same exact issue, but I am curious about your implementation. I am also attempting to add a new action to a built in portlet (shopping) and wondering where I put the struts-config action declaration? I do have an ext plugin with a struts-config-ext.xml, but I would think I could add something via the hook as well?
How did you declare your action-mapping? Or did you not have to?
Thank you!
Brian
I am not having the same exact issue, but I am curious about your implementation. I am also attempting to add a new action to a built in portlet (shopping) and wondering where I put the struts-config action declaration? I do have an ext plugin with a struts-config-ext.xml, but I would think I could add something via the hook as well?
How did you declare your action-mapping? Or did you not have to?
Thank you!
Brian
Mika Koivisto, modificado hace 9 años.
RE: Trying to add a new Struts action for Blog
Liferay Legend Mensajes: 1519 Fecha de incorporación: 7/08/06 Mensajes recientes
You should be extending BaseStrutsPortletAction and not BaseStrutsAction which is for actions triggered under /c