Foren
Struts portlet
mohammad azaruddin, geändert vor 11 Jahren.
Struts portlet
Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
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
mohammad azaruddin, geändert vor 10 Jahren.
RE: Struts portlet
Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
Hi all
Is it possible .....?
Vilmos Papp, geändert vor 10 Jahren.
RE: Struts portlet
Liferay Master Beiträge: 529 Beitrittsdatum: 21.10.10 Neueste Beiträge<portlet:actionurl name="myFunction" var="myFuncionURL" />
mohammad azaruddin, geändert vor 10 Jahren.
RE: Struts portlet
Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
Hi
Vilmos Papp
Thank you
This is what i was looking for And in sample-struts-portlet all methods are overridden method.so i dont think they used this approach
Vilmos Papp
Thank you
This is what i was looking for And in sample-struts-portlet all methods are overridden method.so i dont think they used this approach
Apoorva Prakash, geändert vor 10 Jahren.
RE: Struts portlet
Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste Beiträgemohammad 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
mohammad azaruddin, geändert vor 10 Jahren.
RE: Struts portlet
Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
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....?
Vilmos Papp, geändert vor 10 Jahren.
RE: Struts portlet
Liferay Master Beiträge: 529 Beitrittsdatum: 21.10.10 Neueste Beiträge
Probably you could check out our demo struts portlet as well: https://github.com/liferay/liferay-plugins/tree/master/portlets/sample-struts-liferay-portlet
mohammad azaruddin, geändert vor 10 Jahren.
RE: Struts portlet
Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
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"));
Apoorva Prakash, geändert vor 10 Jahren.
RE: Struts portlet
Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste Beiträgemohammad 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
mohammad azaruddin, geändert vor 10 Jahren.
RE: Struts portlet
Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
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>
Apoorva Prakash, geändert vor 10 Jahren.
RE: Struts portlet
Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste Beiträgemohammad 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
mohammad azaruddin, geändert vor 10 Jahren.
RE: Struts portlet
Expert Beiträge: 492 Beitrittsdatum: 17.09.12 Neueste Beiträge
Hi Apoorva Prakash
Thank You the article is helpful
Thank You the article is helpful
Apoorva Prakash, geändert vor 10 Jahren.
RE: Struts portlet
Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste Beiträgemohammad azaruddin:
Hi Apoorva Prakash
Thank You the article is helpful
Welcome Azhar...