在Hook环境中添加自定义方法? [英] adding custom methods in Hook environment?

查看:228
本文介绍了在Hook环境中添加自定义方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用钩子将新方法添加到CalEventLocalServiceImpl中...

i am adding a new method into CalEventLocalServiceImpl using hook...

我的代码是..

public class MyCalendarLocalServiceImpl extends CalEventLocalServiceWrapper {

    public MyCalendarLocalServiceImpl(CalEventLocalService calEventLocalService) {
        super(calEventLocalService);
        // TODO Auto-generated constructor stub
    }

    public List getUserData(long userId) throws SystemException{
        DynamicQuery query=DynamicQueryFactoryUtil.forClass(CalEvent.class)
        .add(PropertyFactoryUtil.forName("userId").eq(userId));
        List deatils=CalEventLocalServiceUtil.dynamicQuery(query);

        return deatils;
    }
}

liferay-hook.xml:

<service>
    <service-type>
        com.liferay.portlet.calendar.service.CalEventLocalService
    </service-type>
    <service-impl>
        com.liferay.portlet.calendar.service.impl.MyCalendarLocalServiceImpl
    </service-impl>
</service>

我的问题是如何使用jsp文件中的 getUserData . 有人可以帮我吗....

my question is how to use getUserData from jsp file. Can anybody help me out....

我认为您没有提出我的问题...我想要基于日历中 USERID 的事件列表...以完成此任务我需要做的事情?

i think u didn't gt my question...i want list of events based on USERID from Calendar ...to achieve this task what i need to do??

推荐答案

我假设getUserData()没有被覆盖,而是一个新方法(当前无法查找).覆盖服务时,您不能执行此操作.取而代之的是,您必须添加新服务并将其提供给门户网站.

I assume getUserData() is not overridden but a new method (can't look up currently). This is not what you can do when overriding a service. Instead you'd have to add a new Service and make it available to the portal.

请记住,门户网站类加载器中正在运行一个自定义的(已挂钩")jsp,而钩子的类加载器中正在运行您的重载服务.因此,如果您创建一个新服务,并使该service.jar对Liferay可用(例如,在全局类路径上),则可以从JSP调用它. Liferay服务的接口无法通过过载的服务进行扩展.

Remember that a customized ("hooked") jsp is running in the portal classloader, while your overloaded service is running in the hook's classloader. Thus, if you create a new service and make the service.jar available to Liferay (e.g. on the global classpath) you can call it from JSPs. The interface of Liferay services can not be extended through an overloaded service.

如果getUserData()已经存在于接口中(如我所说,我目前无法查找),则只需从jsp调用CalendarLocalServiceUtil,它将被委派给您的包装器.

In case getUserData() is already in the interface (as I said I can't look up currently), you just need to call the CalendarLocalServiceUtil from your jsp and it will be delegated to your wrapper.

这篇关于在Hook环境中添加自定义方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆