-1

もう一方のカスタム ポートレットで 1 つの add 関数を呼び出しているときに、同じ問題が発生します。ポートレット クラスに addrestaurant(restaurant) を使用したメソッドが 1 つあります。ビューからそれを呼び出してデータを追加すると、次のエラーが発生します。

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)

私はすべてのことを確認しましたが、なぜこれが起こっているのかを見つける理由はまだありません..新しいポートレットを作成するときに毎回それが来るのかわかりません..

以下は私の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;
        }
    }

以下は私のrestualntActionutilクラスです

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

ここにあなたを置いてもらえますportlet.xmlか?クラスを指定していないようです。そのため、Liferay はデフォルトの MVCPortlet クラスを使用しようとしました。そしてもちろん、addrestaurant()方法はありません。これはコードの問題ではなく、構成の問題です。

于 2012-10-22T12:28:12.647 に答える