深入liferay portal核心之一 portlet扩展分析
2008-06-25 21:52
211 查看
JSR168规范规定,所有Portlet都必须直接地或者间接地实现Portlet接口。同时,也提供了一个叫GenericPortlet的基类,该类继承了Portlet接口,统一定义了可供 Portal 容器识别和调用的方法。因此,大部分情况下,开发人员只需要继承GenericPortlet这个基类,而不必直接实现Portlet接口。
Liferay Portal也是一个支持JSR168的企业门户,我们来看看在它的内部,是如何扩展GenericPortlet的。
1) 它自定义类LiferayPortlet扩展GenericPortlet,增加几个模式,如CONFIG、EDIT_GUEST、EDIT_DEFAULT、PREVIEW、PRINT.
2) 定义class StrutsPortlet,扩展LiferayPortlet,初始化模式参数,并定义了process action的过程。在liferay中,配置文件portlet-custom.xml中配置各portlet的一些,其中有个很重要的参数是portlet-class,该参数的值一般是com.liferay.portlet.StrutsPortlet,表明该portlet是struts portlet.
3) 定义类JSPPortlet,扩展LiferayPortlet,该类在liferay中用不上,所以这边不做研究。简单提一下,如果参数portlet-class配置的值是JSPPortlet,那么该portlet是JSPPortlet。
4) 注意到有个IFramePortlet扩展了StrutsPortlet,大家可能就有疑问了,为什么在liferay中,有那么多的portlet,单单就它需要扩展StrutsPortlet,通过查看该类的源代码:
[align=left]可以清楚的知道,IFramePortlet定义自身所需要的default action,当portlet没有配置editAction和viewAction的值时,在代码中赋予默认的值。[/align]
下面图示了这个继承、扩展关系:
Liferay Portal也是一个支持JSR168的企业门户,我们来看看在它的内部,是如何扩展GenericPortlet的。
1) 它自定义类LiferayPortlet扩展GenericPortlet,增加几个模式,如CONFIG、EDIT_GUEST、EDIT_DEFAULT、PREVIEW、PRINT.
2) 定义class StrutsPortlet,扩展LiferayPortlet,初始化模式参数,并定义了process action的过程。在liferay中,配置文件portlet-custom.xml中配置各portlet的一些,其中有个很重要的参数是portlet-class,该参数的值一般是com.liferay.portlet.StrutsPortlet,表明该portlet是struts portlet.
3) 定义类JSPPortlet,扩展LiferayPortlet,该类在liferay中用不上,所以这边不做研究。简单提一下,如果参数portlet-class配置的值是JSPPortlet,那么该portlet是JSPPortlet。
4) 注意到有个IFramePortlet扩展了StrutsPortlet,大家可能就有疑问了,为什么在liferay中,有那么多的portlet,单单就它需要扩展StrutsPortlet,通过查看该类的源代码:
public static final String DEFAULT_EDIT_ACTION = "/iframe/edit"; public static final String DEFAULT_VIEW_ACTION = "/iframe/view"; public void init(PortletConfig config) throws PortletException { super.init(config); if (Validator.isNull(editAction)) { editAction = DEFAULT_EDIT_ACTION; } if (Validator.isNull(viewAction)) { viewAction = DEFAULT_VIEW_ACTION; } }
[align=left]可以清楚的知道,IFramePortlet定义自身所需要的default action,当portlet没有配置editAction和viewAction的值时,在代码中赋予默认的值。[/align]
下面图示了这个继承、扩展关系:
![](http://p.blog.csdn.net/images/p_blog_csdn_net/chg2008/ClassDiagram1.png)
相关文章推荐
- Liferay Portal服务器上的portlet开发_2: 在EXT中开发最简单的JSP
- Android 核心分析 之七------Service深入分析
- Liferay代码分析与扩展——用户服务
- 深入分析JavaWeb 21 -- JSTL核心标签库
- Android 核心分析 之七------Service深入分析
- Liferay中如何在Portal级别的Session中放入属性然后在Portlet中使用
- Liferay Portal CE 6.2 Portlet 配置(Configuration) 开发
- Liferay代码分析与扩展——用户服务
- liferay-portal中卸载portlet
- Android 核心分析 之六------Service深入分析 .
- Android 核心分析 ------Service深入分析
- 学习笔记8:《大型网站技术架构 核心原理与案例分析》之 随需应变:网站的可扩展架构
- 【Liferay Portal指南四】——JSP Portlet开发
- Android 核心分析 之七------Service深入分析
- Liferay Portal(四)jsp中URL传参给portlet
- liferay Portal CE6.2 新开发portlet如何设置权限(Security and Permission resources )
- Android 核心分析 之七------Service深入分析
- Portal學習--核心類分析
- 深入分析JavaWeb Item21 -- JSTL核心标签库