Note that there are some explanatory texts on larger screens.

plurals
  1. POResourceActionsException While adding the value in database in my own portal
    primarykey
    data
    text
    <p>I am having Following error while adding some value to database.</p> <p>My Error trace is as follows</p> <pre><code>... 10:06:10,730 INFO [RestaurantPortlet:35] Inside addRegistration 10:06:10,731 INFO [RestaurantPortlet:40] {Resto_ID=0, Name=KFC, Location=AHMEDABAD, Room_Count=0, Table_Count=0, userId=10196, companyId=10154, groupId=10180, Reseller_ID=0} com.liferay.portal.ResourceActionsException: There are no actions associated with the resource com.test.model.Restaurant at com.liferay.portal.service.impl.ResourceLocalServiceImpl.validate(ResourceLocalServiceImpl.java:1348)....... </code></pre> <p>So Whats the mistake in my acrtion methods?</p> <p>This is my serviceiml class</p> <pre><code>/** * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.test.service.impl; import java.util.Collections; import java.util.List; import com.test.model.Restaurant; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; import com.test.service.base.RestaurantServiceBaseImpl; /** * The implementation of the restaurant remote service. * * &lt;p&gt; * All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy their definitions into the {@link com.test.service.RestaurantService} interface. * * &lt;p&gt; * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS credentials because this service can be accessed remotely. * &lt;/p&gt; * * @author bhavik.kama * @see com.test.service.base.RestaurantServiceBaseImpl * @see com.test.service.RestaurantServiceUtil */ public class RestaurantServiceImpl extends RestaurantServiceBaseImpl { public Restaurant addreRestaurant(Restaurant restoParam) { Restaurant restoVar; try { restoVar = restaurantPersistence.create((int) counterLocalService .increment(Restaurant.class.toString())); } catch (SystemException e) { e.printStackTrace(); return restoVar = null; } try { resourceLocalService.addResources(restoParam.getCompanyId(), restoParam.getGroupId(), restoParam.getUserId(), Restaurant.class.getName(), restoParam.getPrimaryKey(),false, true, true); } catch (PortalException e) { e.printStackTrace(); return restoVar = null; } catch (SystemException e) { e.printStackTrace(); return restoVar = null; } restoVar.setResto_ID(restoParam.getResto_ID()); restoVar.setName(restoParam.getName()); restoVar.setLocation(restoParam.getLocation()); restoVar.setRoom_Count(restoParam.getRoom_Count()); restoVar.setTable_Count(restoParam.getRoom_Count()); restoVar.setCompanyId(restoParam.getCompanyId()); restoVar.setUserId(restoParam.getUserId()); restoVar.setGroupId(restoParam.getGroupId()); restoVar.setReseller_ID(restoParam.getReseller_ID()); try { return restaurantPersistence.update(restoVar, false); } catch (SystemException e) { e.printStackTrace(); return restoVar = null; } } public List&lt;Restaurant&gt; getAllerRestaurants() { try { return restaurantPersistence.findAll(); } catch (SystemException e) { e.printStackTrace(); return Collections.emptyList(); } } public List&lt;Restaurant&gt; getAllreRestaurants(long groupId, String title) { try { return restaurantPersistence.findByGroupId(groupId); } catch (SystemException e) { e.printStackTrace(); return Collections.emptyList(); } } } </code></pre> <p>My Portlet class is as follows...</p> <pre><code>package com.test.portlet; import java.util.ArrayList; import java.util.List; import javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.test.model.Restaurant; import com.test.service.RestaurantServiceUtil; import com.test.util.RestaurantActionUtil; import com.test.util.RestaurantValidator; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.servlet.SessionErrors; import com.liferay.portal.kernel.servlet.SessionMessages; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.theme.ThemeDisplay; import com.liferay.util.bridges.mvc.MVCPortlet; /** * Portlet implementation class BooksPortlet */ public class RestaurantPortlet extends MVCPortlet { private static Log log = LogFactory.getLog(RestaurantPortlet.class); private static String errorJSP="/jsps/error.jsp" ; public void addRestaurant(ActionRequest request, ActionResponse response) { log.info("Inside addRegistration"); List&lt;String&gt; errors=new ArrayList&lt;String&gt;(); Restaurant resto=RestaurantActionUtil.getRestaurantFromRequest(request); //boolean bookValid=RestaurantValidator.validateBook(resto, errors); log.info(resto); Restaurant test=RestaurantServiceUtil.addreRestaurant(resto); if(test==null) { log.error("REsto was Found Null"); //response.setRenderParameter("jspPage", errorJSP); return ; } SessionMessages.add(request,"book-added"); return ; } } /* public void deleteBooks(ActionRequest request, ActionResponse response) { long bookId = ParamUtil.getLong(request, "bookId"); ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute( WebKeys.THEME_DISPLAY); if (Validator.isNotNull(bookId)) { BooksLocalServiceUtil.deleteBooks(bookId, themeDisplay.getCompanyId()); SessionMessages.add(request, "book-deleted"); } else { SessionErrors.add(request, "error-deleting"); } } */ </code></pre> <p>Please Guide me that where am doing mistake..</p> <p>My default.xml in resource action folder</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;resource-action-mapping&gt; &lt;portlet-resource&gt; &lt;portlet-name&gt;RestaurantPortlet&lt;/portlet-name&gt; &lt;permissions&gt; &lt;supports&gt; &lt;action-key&gt;addRestaurant&lt;/action-key&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/supports&gt; &lt;community-defaults&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/community-defaults&gt; &lt;guest-defaults&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/guest-defaults&gt; &lt;guest-unsupported&gt; &lt;action-key&gt;addRestaurant&lt;/action-key&gt; &lt;/guest-unsupported&gt; &lt;/permissions&gt; &lt;/portlet-resource&gt; &lt;model-resource&gt; &lt;model-name&gt;com.test.Restaurant&lt;/model-name&gt; &lt;portlet-ref&gt; &lt;portlet-name&gt;RestaurantPortlet&lt;/portlet-name&gt; &lt;/portlet-ref&gt; &lt;permissions&gt; &lt;supports&gt; &lt;action-key&gt;addRestaurant&lt;/action-key&gt; &lt;action-key&gt;DELETE&lt;/action-key&gt; &lt;action-key&gt;UPDATE&lt;/action-key&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/supports&gt; &lt;community-defaults&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/community-defaults&gt; &lt;guest-defaults&gt; &lt;action-key&gt;VIEW&lt;/action-key&gt; &lt;/guest-defaults&gt; &lt;guest-unsupported&gt; &lt;action-key&gt;UPDATE&lt;/action-key&gt; &lt;action-key&gt;DELETE&lt;/action-key&gt; &lt;/guest-unsupported&gt; &lt;/permissions&gt; &lt;/model-resource&gt; &lt;/resource-action-mapping&gt; </code></pre> <p>This is my restuarntactionutilclass and i have doubt that something goes wrong here..but don't know am i right or wrong.please check it...</p> <pre><code>package com.test.util; import java.util.List; import javax.portlet.ActionRequest; import com.test.model.Restaurant; import com.test.model.impl.RestaurantImpl; import com.liferay.portal.kernel.util.ParamUtil; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.theme.ThemeDisplay; /*Apr 20, 2011 5:17:37 PM */ public class RestaurantActionUtil { public static Restaurant getRestaurantFromRequest(ActionRequest request) { ThemeDisplay themeDisplay = (ThemeDisplay) request .getAttribute(WebKeys.THEME_DISPLAY); String Name = ParamUtil.getString(request, "Name", "Name Not Availible"); String Location = ParamUtil.getString(request, "Location", "Location Not Availible"); String table_count = ParamUtil.getString(request, "Table_Count", "0"); String room_count=ParamUtil.getString(request, "Room_Count","0"); String reseller_id=ParamUtil.getString(request, "Reseller_ID","0"); int table = Integer.parseInt(table_count); int room = Integer.parseInt(room_count); int reseller = Integer.parseInt(reseller_id); Restaurant resto = new RestaurantImpl(); resto.setName(Name); resto.setLocation(Location); resto.setTable_Count(table); resto.setRoom_Count(room); resto.setReseller_ID(reseller); resto.setCompanyId(themeDisplay.getCompanyId()); resto.setGroupId(themeDisplay.getLayout().getGroupId()); resto.setUserId(themeDisplay.getUserId()); return resto; } } </code></pre> <p>The object resto is always coming null</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload