Foren

struts portlet action mapping url

subhash ranjan, geändert vor 16 Jahren.

struts portlet action mapping url

New Member Beiträge: 19 Beitrittsdatum: 10.09.07 Neueste Beiträge
Hi all,
I have a problem regarding struts portlet url. How can be get it in action classes and jsps .I am using sample struts portlet configuration. I tried with this but it creating a different url:

<%
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("struts_action", "/library_admin/categorymanage.do?parameter=toCategoryDelete");
%>
I need this url:

?p_p_id=library_admin_WAR_struts_portlet&p_p_action=0&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_library_admin_WAR_struts_portlet__spage=%2Fportlet_action%2Flibrary_admin%2Fcategorymanage%3Fparameter%3DtoCategoryDelete&_library_admin_WAR_struts_portlet_parameter=toCategoryDelete

But the above scriplet creating this:

?p_p_id=library_admin_WAR_struts_portlet&p_p_action=1&p_p_state=normal&p_p_mode=view&p_p_col_id=column-1&p_p_col_count=1&_library_admin_WAR_struts_portlet_struts_action=%2Flibrary_admin%2Fcategorymanage.do%3Fparameter%3DtoCategoryDelete

Thanks
subhash
subhash ranjan, geändert vor 16 Jahren.

RE: struts portlet action mapping url

New Member Beiträge: 19 Beitrittsdatum: 10.09.07 Neueste Beiträge
Hi everybody,

I got the solution. But I have a problem at one place. First the solution:
In the jsps you will get url using this. Make sure in your jsp you have these:

<%@ page import="javax.portlet.PortletURL" %>
<portlet:defineObjects />
:
---------- for struts dispatch action----------------------------
<%
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("_spage","/portlet_action/library_admin/categorymanage?parameter=toCategoryDelete");
portletURL.setParameter("parameter","toCategoryDelete");
%>
or
<%
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("_spage","/portlet_action/library_admin/categorymanage");
portletURL.setParameter("parameter","toCategoryDelete");
%>
For use in javascript or for form action: "<%= portletURL.toString() %>"

--------------- for struts action---------------------------------
<%
PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("_spage","/portlet_action/library_admin/categorymanage");
%>
For use in javascript or for form action: "<%= portletURL.toString() %>"

For use in action classs:---------------------------------------
import javax.portlet.PortletURL;
import javax.portlet.RenderResponse;
//other imports
public class Myclass extends Action{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req,
HttpServletResponse res)
throws Exception {
RenderResponse renderResponse = (RenderResponse)req.getAttribute("javax.portlet.response");

PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("_spage", "/portlet_action/library_user/extendReqAction");
String url=portletURL.toString();

//for passing parameter as I do for jmesa column link
html.a().href().quote().append(url+"&id="+bId).quote().close();
}
}
Now the problem I am facing:---------------------------------------------

These are working for classes which are invoked through struts link. But the same thing is not working in one class which is invoked through struts form action. Like I have a form entry & based on form entry there is a criteria search & I forwarded user to different page where a table is populated with user criteria and links are available for some action in columns.For these columns link I need portlet url.I use the same code above which is working elsewhere but throwing error here:

java.lang.ClassCastException: com.liferay.portlet.ActionResponseImpl

on line

RenderResponse renderResponse = (RenderResponse)req.getAttribute("javax.portlet.response");

Is any body having any idea why this happening?

Thanks
subhash
thumbnail
praveen kumar, geändert vor 16 Jahren.

RE: struts portlet action mapping url

Junior Member Beiträge: 52 Beitrittsdatum: 16.11.07 Neueste Beiträge
Hi Subash,

I am also facing the same java.lang.ClassCastException: com.liferay.portlet.ActionResponseImpl .if you found the solution could you help to get out of this error please..its urgentemoticon
thumbnail
manasa chandri, geändert vor 13 Jahren.

RE: struts portlet action mapping url

Regular Member Beiträge: 152 Beitrittsdatum: 28.09.10 Neueste Beiträge
hi,

I am working in the struts plug-in portlet.

Can we create the process action and render method in struts plug-in portlet?

Instead of using the execute method.

can anybody know the solution.

Please reply me as soon as possible.

Thanks in advance.