Foren
Call different action methods in portlet
Peter Hellstrand, geändert vor 12 Jahren.
Call different action methods in portlet
Junior Member Beiträge: 26 Beitrittsdatum: 11.10.11 Neueste Beiträge
This is my edit action in my admin_actions.jsp. Where is this "editURL.toString() " comming from?
I ahve implemented
But it never gets called. How can I call it?
I have a similar
that gets called from my view.jsp like this
What is the difference in the both cases? Clicking on the edit just gives me
and a blank page.
System.out.println("....................................I am being called ");
is never printed. Please explain this to me.
<liferay-ui:icon-menu>
 <c:if test="<%= permissionChecker.hasPermission(groupId, name, primKey, ActionKeys.UPDATE) %>">
<portlet:actionurl name="editProduct" var="editURL">
<portlet:param name="resourcePrimKey" value="<%= primKey %>" />
</portlet:actionurl>
<liferay-ui:icon image="edit" message="Edit" url="
<%= editURL.toString() %>" /></c:if></liferay-ui:icon-menu>
I ahve implemented
public void editProduct(ActionRequest request, ActionResponse response) throws Exception{
long productKey = ParamUtil.getLong(request, "resourcePrimKey");
System.out.println("....................................I am being called ");
if(Validator.isNotNull(productKey)) {
PRProduct product = PRProductLocalServiceUtil.getPRProduct(productKey);
response.setRenderParameter("jspPage", editProductJsp);
}
}
But it never gets called. How can I call it?
I have a similar
public void addProduct(ActionRequest request, ActionResponse response ) throws PortalException, SystemException {
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
PRProduct product = ActionUtil.productFromRequest(request);
long companyId = themeDisplay.getCompanyId();
long groupId = themeDisplay.getLayout().getGroupId();
List<string> errors = new ArrayList<string>();
product.setCompanyId(companyId);
product.setGroupId(groupId);
if(ProdRegValidator.validateProduct(product,errors)) {
PRProductLocalServiceUtil.addProduct(product, themeDisplay.getUserId());
SessionMessages.add(request, "product-saved-successfully");
} else {
System.out.println("Got errors .... " + errors);
SessionErrors.add(request, "fields-required");
}
}</string></string>
that gets called from my view.jsp like this
<portlet:actionurl name="addProduct" var="addProductURL" />
<aui:form action="<%= addProductURL.toString() %>" method="post">
<aui:fieldset>
<aui:input name="productName" size="45" />
<aui:input name="productSerial" size="45" />
<aui:button-row>
<aui:button type="submit" />
</aui:button-row>
</aui:fieldset>
</aui:form>
What is the difference in the both cases? Clicking on the edit just gives me
http://localhost:8080/group/control_panel/%3C%=%20editProductURL.toString()%20%%3E
and a blank page.
System.out.println("....................................I am being called ");
is never printed. Please explain this to me.
Sandeep Nair, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
In order for it to work you have to add in your jsp at the top the following
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:actionURL name="actionNAme" var="actionURL"/>
Here the value in name(actionName) maps to method in your MVC Portlet and actionURL is the url which invokes that.
These are all part of taglib
regards,
Sandeep
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:actionURL name="actionNAme" var="actionURL"/>
Here the value in name(actionName) maps to method in your MVC Portlet and actionURL is the url which invokes that.
These are all part of taglib
regards,
Sandeep
Sandeep Nair, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Heres a better explanation
http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/writing-the-my-greeting-portlet
Regards,
Sandeep
http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/writing-the-my-greeting-portlet
Regards,
Sandeep
Peter Hellstrand, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Junior Member Beiträge: 26 Beitrittsdatum: 11.10.11 Neueste Beiträge
This already was in my if statement.
And this was in my init.jsp
<portlet:actionurl name="editProduct" var="editURL"></portlet:actionurl>
And this was in my init.jsp
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
Sandeep Nair, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
in the form just use editURL.toString() if you have put editURL in var
<form method="post" name="<portlet:namespace/>fm" action="<%=editURL.toString()%>">
</form>
<form method="post" name="<portlet:namespace/>fm" action="<%=editURL.toString()%>">
</form>
Peter Hellstrand, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Junior Member Beiträge: 26 Beitrittsdatum: 11.10.11 Neueste BeiträgeSandeep Nair:
in the form just use editURL.toString() if you have put editURL in var
<form method="post" name="<portlet:namespace/>fm" action="<%=editURL.toString()%>">
</form>
Thanks
I am just trying to follow an example from a book. There is no form?
<liferay-ui:icon-menu>
 <c:if test="<%= permissionChecker.hasPermission(groupId, name, primKey, ActionKeys.UPDATE) %>">
<portlet:actionurl name="editProduct" var="editURL">
<portlet:param name="resourcePrimKey" value="<%= primKey %>" />
</portlet:actionurl>
<liferay-ui:icon image="edit" message="Edit" url="
<%= editURL.toString() %>" /></c:if></liferay-ui:icon-menu>
Sandeep Nair, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Hi Peter,
Is it possible for you to attach the zip of the portlet. I will try to deploy it and let you know where the problem is
Regards,
Sandeep
Is it possible for you to attach the zip of the portlet. I will try to deploy it and let you know where the problem is
Regards,
Sandeep
Peter Hellstrand, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Junior Member Beiträge: 26 Beitrittsdatum: 11.10.11 Neueste BeiträgeSandeep Nair:
Hi Peter,
Is it possible for you to attach the zip of the portlet. I will try to deploy it and let you know where the problem is
Regards,
Sandeep
Thank you very much for helping me with this.
I hope you got everyhing you need.
Sandeep Nair, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
Hi Peter,
Can you please try the attached zip and see if Edit is working for you. Basically when i opened file admin_actions.jsp in my texteditor there some special characters. I just removed those and it seems working for me now
Regards,
Sandeep
Can you please try the attached zip and see if Edit is working for you. Basically when i opened file admin_actions.jsp in my texteditor there some special characters. I just removed those and it seems working for me now
Regards,
Sandeep
Peter Hellstrand, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Junior Member Beiträge: 26 Beitrittsdatum: 11.10.11 Neueste Beiträge
Now it work
maybe its related to
Are you sing eclipse or what IDE are you using?
Well tahnk you so much for helping me. I have less than one week liferay experience
maybe its related to
http://www.liferay.com/community/forums/-/message_boards/message/11081379
Are you sing eclipse or what IDE are you using?
Well tahnk you so much for helping me. I have less than one week liferay experience
Sandeep Nair, geändert vor 12 Jahren.
RE: Call different action methods in portlet
Liferay Legend Beiträge: 1744 Beitrittsdatum: 06.11.08 Neueste Beiträge
I used notepad to solve that one, since i knew which jsp may have problem
For projects i normally use eclipse, not Liferay IDE but plain eclipse
Dont worry, Liferay will be seem tough to decipher at first but as you go on using it for 2 to 3 months you will get used to it. The documentation is improving and the community is very active, so most of your problems will be solved
Regards,
Sandeep
For projects i normally use eclipse, not Liferay IDE but plain eclipse
Dont worry, Liferay will be seem tough to decipher at first but as you go on using it for 2 to 3 months you will get used to it. The documentation is improving and the community is very active, so most of your problems will be solved
Regards,
Sandeep