留言板
Struts portlet
Hi
How can i achieve this
Azhar
Thanks in advance
In normal MVC portlet we can hit perticular method using this snipplet
myActionURL.setParameter(ActionRequest.ACTION_NAME, "myMethod");
How can achiev same in struts portlet.
<portlet:actionURL var="myActionURL">
<portlet:param name="struts_action" value="/sample_struts_liferay_portlet/subscribe" />
</portlet:actionURL>
this actionURL hit the processAction method of class defined in struts-config.xml.But i wanted to hit perticular method (myMethod in this case)
How can i achieve this
Azhar
Thanks in advance
Hi all
Is it possible .....?
mohammad azaruddin:
Hi
In normal MVC portlet we can hit perticular method using this snipplet
myActionURL.setParameter(ActionRequest.ACTION_NAME, "myMethod");
How can achiev same in struts portlet.
<portlet:actionURL var="myActionURL">
<portlet:param name="struts_action" value="/sample_struts_liferay_portlet/subscribe" />
</portlet:actionURL>
this actionURL hit the processAction method of class defined in struts-config.xml.But i wanted to hit perticular method (myMethod in this case)
How can i achieve this
Azhar
Thanks in advance
Hello Azhar,
The way you are trying to achieve this, I am afraid this is not possible.
Instead of MVCPortlet, you shout try extending Apache Strut's Action class. See the following class blueprint:
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class SampleAction extends Action {
public ActionForward execute(
ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return mapping.findForward("/html/sample/view.jsp");
}
}
}
HTH.
Thanks and Regards,
Apoorva Prakash
HI Apoorva Prakash
Thank you for your answer
How if i'm extending Action class and want to jump to perticular custom method....?
Thank you for your answer
How if i'm extending Action class and want to jump to perticular custom method....?
Probably you could check out our demo struts portlet as well: https://github.com/liferay/liferay-plugins/tree/master/portlets/sample-struts-liferay-portlet
Hi
In sample sturts portlet example renderURL is created using this sniplet
And as mentioned in struts-config.xml it is going to action class
In sample sturts portlet example renderURL is created using this sniplet
<a href="<portlet:renderURL><portlet:param name="struts_action" value="/sample_struts_liferay_portlet/x" /></portlet:renderURL>">Render</a>
And as mentioned in struts-config.xml it is going to action class
<action path="/sample_struts_liferay_portlet/x" type="com.liferay.samplestrutsliferay.struts.action.XAction">
<exception key="error.sample.exception" type="com.liferay.samplestrutsliferay.SampleException" path="portlet.sample_struts_liferay_portlet.sample_exception" />
<forward name="portlet.sample_struts_liferay_portlet.x" path="portlet.sample_struts_liferay_portlet.x" />
</action>
So my doubt is can we render,Without going to action class....?And without overidding render method of action class,
return mapping.findForward(
getForward(
renderRequest, "portlet.sample_struts_liferay_portlet.x"));
mohammad azaruddin:
Hi
In sample sturts portlet example renderURL is created using this sniplet
<a href="<portlet:renderURL><portlet:param name="struts_action" value="/sample_struts_liferay_portlet/x" /></portlet:renderURL>">Render</a>
And as mentioned in struts-config.xml it is going to action class
<action path="/sample_struts_liferay_portlet/x" type="com.liferay.samplestrutsliferay.struts.action.XAction">
<exception key="error.sample.exception" type="com.liferay.samplestrutsliferay.SampleException" path="portlet.sample_struts_liferay_portlet.sample_exception" />
<forward name="portlet.sample_struts_liferay_portlet.x" path="portlet.sample_struts_liferay_portlet.x" />
</action>
So my doubt is can we render,Without going to action class....?And without overidding render method of action class,
return mapping.findForward(
getForward(
renderRequest, "portlet.sample_struts_liferay_portlet.x"));
Yes, we can do.
You are probably using renderURL and ActionURL wrong.
ActionURL - forwards your request to processAction()
RenderURL - forwards your request to doView()
You should not add the the struts action in renderURL, but in action URL.
HTH
Hi apoorva
In example portlet they were using same param name&value for creating renderURL as well as actionURL.
In example portlet they were using same param name&value for creating renderURL as well as actionURL.
sample-struts-liferay-portlet example portlet they use
<a href="<portlet:renderURL><portlet:param name="struts_action" value="/sample_struts_liferay_portlet/x" /></portlet:renderURL>">Render</a>
sniplet to create renderURL..You can find sample portlet here
<a href="<portlet:actionURL><portlet:param name="struts_action" value="/sample_struts_liferay_portlet/x" /><portlet:param name="x_param" value="bad_x_value" /></portlet:actionURL>">Action</a>
mohammad azaruddin:
HI Apoorva Prakash
Thank you for your answer
How if i'm extending Action class and want to jump to perticular custom method....?
Hey Azhar,
All the rules of Struts Portlet applies here. But if you are looking for jumping on particular function then you can create portlet with multiple actions as suggested by Vilmos Papp.
You can seek some help from here and here.
HTH.
Thanks and Regards,
Apoorva Prakash