Planned maintenance is scheduled for the week of June 15th - the exact date and time will be announced soon.
See More Details
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
RE: How to call the struts action (in ext) from a portlet ??
Hi,
I am trying to call the new struts action defined in ext (struts-config-ext.xml, tiles-defs-ext.xml) from a portlet.
But, unfortunately its not working for me, can anybody tell me with an example how to achieve this.
Thanks
Ruchi
I am trying to call the new struts action defined in ext (struts-config-ext.xml, tiles-defs-ext.xml) from a portlet.
But, unfortunately its not working for me, can anybody tell me with an example how to achieve this.
Thanks
Ruchi
From which portlet you are calling struts action, whether it is a plugin portlet or ext?
HI Chintan,
It is a plugin portlet.
Thanks
Ruchi
It is a plugin portlet.
Thanks
Ruchi
Hi Ruchi,
If you are talking about struts path in ext environment(like liferay 5.2.3) then following steps may be helpful.
1- make a PortletURL in the jsp of portlet where you want to use this path.
PortletURL submitURL=renderResponse.createActionURL();
submitURL.setParameter("struts_action","/ext/abc/manage_account/manage");
submitURL.setWindowState(WindowState.NORMAL);
2- Make following entry in the struts-config.xml
<action path="/ext/abc/manage_account/manage" type="com.abc.portlet.manage_account.action.ManageAccountAction" >
<forward name="portlet.ext.abc.manage_account.view" path="portlet.ext.abc.manage_account.view" />
</action>
3- Make following entry in tiles-defs.xml
<definition name="portlet.ext.abc.manage_account.view" extends="portlet">
<put name="portlet_content" value="/portlet/manage/view2.jsp" />
</definition>
view2.jsp is the destination jsp, where you will navigate after following this struts path. In liferay 6 there is no scope of extending these files struts-config.xml or tiles-defs.xml
Hope this will help...
If you are talking about struts path in ext environment(like liferay 5.2.3) then following steps may be helpful.
1- make a PortletURL in the jsp of portlet where you want to use this path.
PortletURL submitURL=renderResponse.createActionURL();
submitURL.setParameter("struts_action","/ext/abc/manage_account/manage");
submitURL.setWindowState(WindowState.NORMAL);
2- Make following entry in the struts-config.xml
<action path="/ext/abc/manage_account/manage" type="com.abc.portlet.manage_account.action.ManageAccountAction" >
<forward name="portlet.ext.abc.manage_account.view" path="portlet.ext.abc.manage_account.view" />
</action>
3- Make following entry in tiles-defs.xml
<definition name="portlet.ext.abc.manage_account.view" extends="portlet">
<put name="portlet_content" value="/portlet/manage/view2.jsp" />
</definition>
view2.jsp is the destination jsp, where you will navigate after following this struts path. In liferay 6 there is no scope of extending these files struts-config.xml or tiles-defs.xml
Hope this will help...
Hi Lalit,
I did almost the same configuration which you mentioned for struts-config.xml & tiles-defs.xml.
In my case its not taking me to the destination jsp... I am on to the same page.(My action class is not even called).
And ya I want to tell you that I am using Liferay 6.... may be thats why its not working for me...
Is their any other way to do the same for liferay 6 ??
Thanks
Ruchi
I did almost the same configuration which you mentioned for struts-config.xml & tiles-defs.xml.
In my case its not taking me to the destination jsp... I am on to the same page.(My action class is not even called).
And ya I want to tell you that I am using Liferay 6.... may be thats why its not working for me...
Is their any other way to do the same for liferay 6 ??
Thanks
Ruchi
Hi I am new to struts and Liferay I don't know how to handle my code in tiles-defs.xml Below is my code
ProjectMgmtAction .java
portlet.xml
struts-config.xml file
I want to call project_costingsheet2.jsp from portlet B
1. onClick of link in Portlet A, I want display project_costingsheet2.jsp in Portlet B.
2. When you directly access Portlet B, project_list.jsp should be displayed.
for project_list.jsp the struts.xml file have
One week I am running behind this...Can anybody help me how to handle my tiles-defs.xml file
Thanks and Regards
Priya
ProjectMgmtAction .java
public class ProjectMgmtAction extends Action{
private Logger logger = LogManager.getLogger(ProjectMgmtAction.class);
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response) throws Exception{
logger.debug("----------------------- inside ProjectMgmtAction --------------------------------");
if (form!=null)
logger.debug("form = " +form.getClass().toString());
else
logger.debug("form=null");
if (form==null){
String userid = request.getRemoteUser();
logger.debug("userid = " +userid);
request.setAttribute("APSE_USER_ID", userid);
}
else if (form instanceof DynaActionForm){
logger.debug("----------------------- inside DynaActionForm --------------------------------");
DynaActionForm actionform=(DynaActionForm)form;
String procode = (String)actionform.get("procode");
request.setAttribute("procode", procode);
}
else
logger.error("form is not instanceof DynaActionForm");
return mapping.findForward("continue");
}
}portlet.xml
<portlet-name>apse-projectmgmt-portlet</portlet-name>
<display-name>APSE Project Management</display-name>
<portlet-class>com.bmtap.apse.projectmgmt.portlet.ProjectMgmtPortlet</portlet-class>
<init-param>
<name>ServletContextProvider</name>
<value>com.liferay.util.bridges.struts.LiferayServletContextProviderWrapper</value>
</init-param>
<init-param>
<name>ViewPage</name>
<value>/apse-projectmgmt-portlet/portlet_action/apse-projectmgmt-portlet/viewAction</value>
</init-param>
<init-param>
<name>view-action</name>
<value>/portlet_action/apse-projectmgmt-portlet/viewAction1</value>
</init-param>struts-config.xml file
<action path="/portlet_action/apse-projectmgmt-portlet/viewAction1" type="com.bmtap.apse.projectmgmt.action.ProjectMgmtAction">
<forward name="continue" path="/jsp/project_costingsheet2.jsp"></forward>
</action>
<action attribute="projectCostingSheetForm2" name="DynaFormBean" path="/apse-projectmgmt-portlet/projectCostingSheetAction2" type="com.bmtap.apse.projectmgmt.action.ProjectMgmtAction">
<forward name="continue" path="/jsp/project_costingsheet2.jsp"></forward>
</action>
I want to call project_costingsheet2.jsp from portlet B
1. onClick of link in Portlet A, I want display project_costingsheet2.jsp in Portlet B.
2. When you directly access Portlet B, project_list.jsp should be displayed.
for project_list.jsp the struts.xml file have
<action path="/portlet_action/apse-projectmgmt-portlet/viewAction" type="com.bmtap.apse.projectmgmt.action.ProjectMgmtAction">
<forward name="continue" path="/jsp/project_list.jsp"></forward>
</action>One week I am running behind this...Can anybody help me how to handle my tiles-defs.xml file
Thanks and Regards
Priya
Hi Ruchi,
My First Question why you prefer EXT , you can do the same thing in the HOOK also.
And if you try to create the new Struts Action then I prefer you to do in hook or Override the Existing one. Because EXT required to Restart the Server..
Please check below link, how to use the Struts action in HOOK.
http://www.liferay.com/community/forums/-/message_boards/message/14288957
http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115
Hope it helps.
Regards,
Amit Doshi
My First Question why you prefer EXT , you can do the same thing in the HOOK also.
And if you try to create the new Struts Action then I prefer you to do in hook or Override the Existing one. Because EXT required to Restart the Server..
Please check below link, how to use the Struts action in HOOK.
http://www.liferay.com/community/forums/-/message_boards/message/14288957
http://www.liferay.com/web/mika.koivisto/blog/-/blogs/7132115
Hope it helps.
Regards,
Amit Doshi
Hello Amit,
Thanks for telling me the other way to do it, I'll go through the links try to do , if it matches my required conditions.
And i'll get back to you.
And as mentined by Lalit in previous post I did the same thing to call the (new) struts action (not overiding the existing one) from my plugin portlet, is it not possible in liferay 6 ??
Regards
Ruchi
Thanks for telling me the other way to do it, I'll go through the links try to do , if it matches my required conditions.
And i'll get back to you.
And as mentined by Lalit in previous post I did the same thing to call the (new) struts action (not overiding the existing one) from my plugin portlet, is it not possible in liferay 6 ??
Regards
Ruchi
Hello friends,
Its working now....
Their was problem in "PortletUrl"
Now my portlet Url is like this :
PortletURL redirectURL = PortletURLFactoryUtil.create(request, PortletKeys.WIKI, themeDisplay.getPlid(), ActionRequest.ACTION_PHASE);
redirectURL.setWindowState(WindowState.NORMAL);
redirectURL.setParameter("my_param_01", "01");
and rest all the configuration is similar as Lalit posted.
Thanks
Ruchi
Its working now....
Their was problem in "PortletUrl"
Now my portlet Url is like this :
PortletURL redirectURL = PortletURLFactoryUtil.create(request, PortletKeys.WIKI, themeDisplay.getPlid(), ActionRequest.ACTION_PHASE);
redirectURL.setWindowState(WindowState.NORMAL);
redirectURL.setParameter("my_param_01", "01");
and rest all the configuration is similar as Lalit posted.
Thanks
Ruchi
for 'post' method below is the alternate approach to call your custom method.
<portlet:actionURL var="myURL1" name="myURL1">
<portlet:param name="struts_action" value="/" />
</portlet:actionURL>
If your method type is 'get' than below is the way to create a url.
<portlet:renderURL var="myURL2">
<portlet:param name="struts_action" value="/blogs/edit_entry" />
</portlet:renderURL>
<portlet:actionURL var="myURL1" name="myURL1">
<portlet:param name="struts_action" value="/" />
</portlet:actionURL>
If your method type is 'get' than below is the way to create a url.
<portlet:renderURL var="myURL2">
<portlet:param name="struts_action" value="/blogs/edit_entry" />
</portlet:renderURL>
Community
Company
Feedback