Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Struts: No action instance for path <your path name> could be created
Hi,
I am using Liferay 6.05 with Tomcat 6.0.26.
What I want to do is:
Adding a button (called: Send E-Mail) to the user view in the control panel in the Liferay Portal. When you are in the user view and then click on "actions", the "Send E-Mail" button should be there.
Therefore I want to use struts and Ext Environment.
I add the "Send E-Mail" button, by customizing the user_action.jsp in the /portlet/enterprise_admin folder with hooks:
I added the following lines to the user_action.jsp:
<portlet:renderURL var="sendMailURL">
<portlet:param name="struts_action" value="/enterprise_admin/mail" />
<portlet:param name="redirect" value="<%= redirect %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(userId) %>" />
</portlet:renderURL>
<liferay-ui:icon
image="Send E-Mail"
url="<%= sendMailURL %>"
I customized the struts-config.xml and the tiles-defs.xml with hooks:
and added the following lines:
My struts-config.xml:
<action path="/enterprise_admin_users/mail" type="com.liferay.portlet.enterpriseadmin.action.MailAction">
<forward name="portlet.enterprise_admin.mail" path="portlet.enterprise_admin.mail" />
<forward name="portlet.enterprise_admin.error" path="portlet.enterprise_admin.error" />
My tiles-defs.xml:
<definition name="portlet.enterprise_admin.mail" extends="portlet.enterprise_admin">
<put name="portlet_content" value="/portlet/enterprise_admin/mail.jsp" />
</definition>
I want to add a Java Action Class in enterprise_admin called MailAction.java with Ext Environment.
Therefore I created a Liferay Ext plug-in Project called: messaging-ext. I created a package com.liferay.portlet.enterpriseadmin.action in docroot/WEB-INF/ext-impl/src. In that package I created the MailAction.java Class.
My MailAction.java:
public class MailAction extends com.liferay.portal.struts.PortletAction {
public void processAction(ActionMapping mapping, ActionForm form,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {
System.out.println("in MainAction processAction");
}
public ActionForward render(ActionMapping mapping, ActionForm form,
PortletConfig portletConfig, RenderRequest renderRequest,
RenderResponse renderResponse) throws Exception {
try {
PortalUtil.getSelectedUser(renderRequest);
} catch (Exception e) {
if (e instanceof PrincipalException) {
SessionErrors.add(renderRequest, e.getClass().getName());
return mapping.findForward("portlet.enterprise_admin.error");
} else {
throw e;
}
}
return mapping.findForward(getForward(renderRequest,
"portlet.enterprise_admin.mail"));
}
In the messaging-ext: my porlet-ext.xml:
<portlet>
<portlet-name>messaging-ext</portlet-name>
<display-name>My Mail Portlet</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param><name>view-action</name>
<value>/enterprise_admin/mail</value></init-param>
<expiration-cache>0</expiration-cache>
<supports><mime-type>text/html</mime-type></supports>
<resource-bundle>
com.liferay.portlet.StrutsResourceBundle
</resource-bundle>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
I also created a mail.jsp in the /portlet/enterprise_admin folder with hooks.
When I press the "Send E-Mail" button I want to be directed to the mail.jsp,
but instead of that, I only got the following error:
[RequestProcessor:296] No action instance for path /enterprise_admin_users/mail could be created
And also the following Exception:
java.lang.ClassCastException: com.liferay.portlet.enterpriseadmin.action.MailAction cannot be cast to org.apache.struts.action.Action
I spent a lot of time to find a solution, but it still doesn't work.
Any ideas how to solve that problem, or what the problem could be?
Thanks for any help.
I am using Liferay 6.05 with Tomcat 6.0.26.
What I want to do is:
Adding a button (called: Send E-Mail) to the user view in the control panel in the Liferay Portal. When you are in the user view and then click on "actions", the "Send E-Mail" button should be there.
Therefore I want to use struts and Ext Environment.
I add the "Send E-Mail" button, by customizing the user_action.jsp in the /portlet/enterprise_admin folder with hooks:
I added the following lines to the user_action.jsp:
<portlet:renderURL var="sendMailURL">
<portlet:param name="struts_action" value="/enterprise_admin/mail" />
<portlet:param name="redirect" value="<%= redirect %>" />
<portlet:param name="p_u_i_d" value="<%= String.valueOf(userId) %>" />
</portlet:renderURL>
<liferay-ui:icon
image="Send E-Mail"
url="<%= sendMailURL %>"
I customized the struts-config.xml and the tiles-defs.xml with hooks:
and added the following lines:
My struts-config.xml:
<action path="/enterprise_admin_users/mail" type="com.liferay.portlet.enterpriseadmin.action.MailAction">
<forward name="portlet.enterprise_admin.mail" path="portlet.enterprise_admin.mail" />
<forward name="portlet.enterprise_admin.error" path="portlet.enterprise_admin.error" />
My tiles-defs.xml:
<definition name="portlet.enterprise_admin.mail" extends="portlet.enterprise_admin">
<put name="portlet_content" value="/portlet/enterprise_admin/mail.jsp" />
</definition>
I want to add a Java Action Class in enterprise_admin called MailAction.java with Ext Environment.
Therefore I created a Liferay Ext plug-in Project called: messaging-ext. I created a package com.liferay.portlet.enterpriseadmin.action in docroot/WEB-INF/ext-impl/src. In that package I created the MailAction.java Class.
My MailAction.java:
public class MailAction extends com.liferay.portal.struts.PortletAction {
public void processAction(ActionMapping mapping, ActionForm form,
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {
System.out.println("in MainAction processAction");
}
public ActionForward render(ActionMapping mapping, ActionForm form,
PortletConfig portletConfig, RenderRequest renderRequest,
RenderResponse renderResponse) throws Exception {
try {
PortalUtil.getSelectedUser(renderRequest);
} catch (Exception e) {
if (e instanceof PrincipalException) {
SessionErrors.add(renderRequest, e.getClass().getName());
return mapping.findForward("portlet.enterprise_admin.error");
} else {
throw e;
}
}
return mapping.findForward(getForward(renderRequest,
"portlet.enterprise_admin.mail"));
}
In the messaging-ext: my porlet-ext.xml:
<portlet>
<portlet-name>messaging-ext</portlet-name>
<display-name>My Mail Portlet</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param><name>view-action</name>
<value>/enterprise_admin/mail</value></init-param>
<expiration-cache>0</expiration-cache>
<supports><mime-type>text/html</mime-type></supports>
<resource-bundle>
com.liferay.portlet.StrutsResourceBundle
</resource-bundle>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
I also created a mail.jsp in the /portlet/enterprise_admin folder with hooks.
When I press the "Send E-Mail" button I want to be directed to the mail.jsp,
but instead of that, I only got the following error:
[RequestProcessor:296] No action instance for path /enterprise_admin_users/mail could be created
And also the following Exception:
java.lang.ClassCastException: com.liferay.portlet.enterpriseadmin.action.MailAction cannot be cast to org.apache.struts.action.Action
I spent a lot of time to find a solution, but it still doesn't work.
Any ideas how to solve that problem, or what the problem could be?
Thanks for any help.
In your portlet-ext.xml you are saying the init param value as /enterprise_admin/mail
<init-param><name>view-action</name>
<value>/enterprise_admin/mail</value></init-param>
and in struts-config.xml you are defining action path as /enterprise_admin_users/mail
path="/enterprise_admin_users/mail" type="com.liferay.portlet.enterpriseadmin.action.MailAction">
keep both of them either enterprise_admin or enterprise_admin_users
Regards,
Sandeep
<init-param><name>view-action</name>
<value>/enterprise_admin/mail</value></init-param>
and in struts-config.xml you are defining action path as /enterprise_admin_users/mail
path="/enterprise_admin_users/mail" type="com.liferay.portlet.enterpriseadmin.action.MailAction">
keep both of them either enterprise_admin or enterprise_admin_users
Regards,
Sandeep
Thanks for your answer, Sandeep.
I've tried it with /enterprise_admin_users/mail.
My portlet-ext.xml:
<init-param><name>view-action</name>
<value>/enterprise_admin_users/mail</value></init-param>
my struts-config.xml:
path="/enterprise_admin_users/mail" type="com.liferay.portlet.enterpriseadmin.action.MailAction">
But I got that Error:
ERROR [RequestProcessor:296] No action instance for path /enterprise_admin_users/mail could be created
java.lang.ClassCastException: com.liferay.portlet.enterpriseadmin.action.MailAction cannot be cast to org.apache.struts.action.Action
I've tried it also with /enterprise_admin/mail, but it doesn't work.
Regards,
Manuel
I've tried it with /enterprise_admin_users/mail.
My portlet-ext.xml:
<init-param><name>view-action</name>
<value>/enterprise_admin_users/mail</value></init-param>
my struts-config.xml:
path="/enterprise_admin_users/mail" type="com.liferay.portlet.enterpriseadmin.action.MailAction">
But I got that Error:
ERROR [RequestProcessor:296] No action instance for path /enterprise_admin_users/mail could be created
java.lang.ClassCastException: com.liferay.portlet.enterpriseadmin.action.MailAction cannot be cast to org.apache.struts.action.Action
I've tried it also with /enterprise_admin/mail, but it doesn't work.
Regards,
Manuel