-1

在使用另一个自定义 portlet 调用一个添加函数时,再次遇到同样的问题。我的 portlet 类中有一种方法,带有 addrestaurant(restaurant),当我从我的视图中调用它以添加数据时,它给了我以下错误。

05:27:42,752 ERROR [http-bio-8080-exec-4][render_portlet_jsp:154] java.lang.NoSuchMethodException: com.liferay.util.bridges.mvc.MVCPortlet.addrestaurant(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
    at java.lang.Class.getMethod(Class.java:1605)
    at com.liferay.portal.kernel.util.MethodCache._get(MethodCache.java:123)
    at com.liferay.portal.kernel.util.MethodCache.get(MethodCache.java:45)
    at com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:149)
    at com.liferay.util.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:250)
    at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:80)
    at com.liferay.util.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:220)
    at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
    at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
    at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
    at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:73)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
    at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
    at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)

我检查了所有的东西,但仍然没有理由我发现为什么会发生这种情况..当我创建新的 portlet 时,每次都不知道它的到来..

以下是我的 restaurantportlet.java 类

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<String> errors=new ArrayList<String>();


        restaurant rest=RestaurantActionUtil.getRestaurantFromRequest(request);
        boolean bookValid=RestaurantValidator.validateRestaurant(rest,errors);
        if(bookValid) {
            try {
                log.info(rest);
                restaurant test=restaurantLocalServiceUtil.addrestaurant(rest);
                if(test==null) {
                    log.error("Restaurant was Found Null");
                    response.setRenderParameter("jspPage", errorJSP);
                    return ;
                }
            } catch (SystemException e) {
                log.error(e);
                /*If there is an error then divert the control to the error page.*/
                response.setRenderParameter("jspPage", errorJSP);
                return ;
            }
            SessionMessages.add(request,"restaurant-added");
            return ;
        }
        else {
             for (String error : errors) {
                    SessionErrors.add(request, error);
                }
                SessionErrors.add(request, "error-while-adding");
                request.setAttribute("rest",rest);
                return ;
        }

    }

以下是我的 restaurantImpl.java 类

 */
public class restaurantLocalServiceImpl extends restaurantLocalServiceBaseImpl {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never reference this interface directly. Always use {@link emenu.advertise.database.service.restaurantLocalServiceUtil} to access the restaurant local service.
     */
    public restaurant addrestaurant(restaurant restParam) {
        restaurant restVar;

        try {
            restVar = restaurantPersistence.create(counterLocalService
                    .increment(advertise.class.toString()));
        } catch (SystemException e) {
            e.printStackTrace();
            return restVar = null;
        }

        try {
            resourceLocalService.addResources(restParam.getGroupId(), restParam.getUserId(),
                    advertise.class.getName(), false);
        } catch (PortalException e) {
            e.printStackTrace();
            return restVar = null;
        } catch (SystemException e) {
            e.printStackTrace();
            return restVar = null;
        }

        restVar.setName(restParam.getName());
        restVar.setAdress(restParam.getAdress());
        restVar.setCity(restParam.getCity());
        restVar.setPin(restParam.getPin());
        restVar.setState(restParam.getState());
        restVar.setCountry(restParam.getCountry());
        restVar.setContactno(restParam.getContactno());
        restVar.setEmail(restParam.getEmail());
        restVar.setWebsite(restParam.getWebsite());
        restVar.setCuisinetype(restParam.getCuisinetype());
        restVar.setPersonalmail(restParam.getPersonalmail());
        restVar.setPersonalname(restParam.getPersonalname());
        restVar.setPersonalPhone(restParam.getPersonalPhone());
        restVar.setNoofemenuagent(restParam.getNoofemenuagent());
        restVar.setLicensekey(restParam.getLicensekey());
        restVar.setRestregId(restParam.getRestId());
        restVar.setNoofdiningtable(restParam.getNoofdiningtable());
        restVar.setAvgnoofcustomermonthly(restParam.getAvgnoofcustomermonthly());
        restVar.setAveragroupagevisit(restParam.getAveragroupagevisit());
        restVar.setImpoflocation(restParam.getImpoflocation());
        restVar.setAvgmonthlycheckamount(restParam.getAvgmonthlycheckamount());
        restVar.setCostperthousandimpression(restParam.getCostperthousandimpression());
        restVar.setAdtypeId(restParam.getAdtypeId());
        //restVar.setNoofdiningtable(restParam.getNoofdiningtable());
        //restVar.setAvgnoofcustomermonthly(restParam.getAvgnoofcustomermonthly());


        restVar.setIsactive(restParam.getIsactive());
        restVar.setCreateddate(restParam.getCreateddate());
        restVar.setLastmodifiedby(restParam.getLastmodifiedby());
        restVar.setModifieddate(restParam.getModifieddate());
        restVar.setGroupId(restParam.getGroupId());
        restVar.setUserId(restParam.getUserId());
        restVar.setIsdeleted(restParam.getIsdeleted());
        restVar.setRestregId(restParam.getRestregId());

        //restVar.setOrganizationId(restParam.getOrganizationId());

        try {
            return restaurantPersistence.update(restVar, false);
        } catch (SystemException e) {
            e.printStackTrace();
            return restVar = null;
        }
    }

以下是我的 restuarntActionutil 类

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");
                    restaurant rest  = new restaurantImpl();
            rest.setName(name);
            rest.setLicensekey(ParamUtil.getString(request, "licesnce_key"));
            rest.setCity(ParamUtil.getString(request, "city"));
            rest.setPin(ParamUtil.getString(request, "pin"));
            rest.setAdress(ParamUtil.getString(request, "adress"));
            rest.setState(ParamUtil.getString(request, "state"));
            rest.setCountry(ParamUtil.getString(request, "country"));
            rest.setContactno(ParamUtil.getString(request, "contact_no"));
            rest.setEmail(ParamUtil.getString(request, "email"));
            rest.setWebsite(ParamUtil.getString(request, "website"));
            rest.setCuisinetype(ParamUtil.getString(request, "cuisine_type"));
            rest.setNoofemenuagent(ParamUtil.getInteger(request, "no_of_emenu_agent"));
            rest.setNoofdiningtable(ParamUtil.getInteger(request, "no_of_dining_table"));
            rest.setPersonalname(ParamUtil.getString(request, "personal_name"));
            rest.setPersonalPhone(ParamUtil.getString(request, "personal_phone"));
            rest.setPersonalmail(ParamUtil.getString(request, "personal_mail"));
            rest.setAveragroupagevisit(ParamUtil.getInteger(request, "avg_age_group_people"));
            rest.setImpoflocation(ParamUtil.getString(request, "imp_of_location"));
            rest.setAvgnoofcustomermonthly(ParamUtil.getInteger(request, "avg_no_of_cust_monthly"));
            rest.setAvgmonthlycheckamount(ParamUtil.getInteger(request, "avg_monthly_check_amount"));
            rest.setAvgmonthlycheckamount(ParamUtil.getLong(request, "cost_per_thousand_impressions"));
            rest.setAdtypeId(ParamUtil.getInteger(request, "ad_type"));
            rest.setIsactive(ParamUtil.getBoolean(request, "isactive"));
            rest.setGroupId(themeDisplay.getLayout().getGroupId());
            rest.setUserId(themeDisplay.getUserId());
            rest.setCreateddate(Calendar.getInstance().getTime());
            rest.setModifieddate(Calendar.getInstance().getTime());
            rest.setLastmodifiedby(themeDisplay.getUserId());
            rest.setRestregId((ParamUtil.getLong(request, "licensekey")));
            rest.setIsdeleted(false);



                        return rest;
        }


    }

以下是我调用此方法的 view.jsp 代码..

<liferay-portlet:actionURL name="addrestaurant" var="addrestoURL"></liferay-portlet:actionURL>

                      <form class="form_validation_ttip" action="<%= addrestoURL.toString()%>" method="post">            

这是我的表单按钮。

<button class="btn" name="btnback" >Save</button>

请任何人都可以指导我吗??我需要找到这背后的主要原因..所以从下一次我会记住我在哪里做错了..

4

1 回答 1

0

Can you put your portlet.xml here? It looks like you did not specify your class, so Liferay tried to use the default MVCPortlet class. And of course, there is no addrestaurant() method. It is not a code problem but a configuration problem.

于 2012-10-22T12:28:12.647 回答