原创  深入liferay portal核心之一 portlet扩展分析 收藏

JSR168规范规定,所有Portlet都必须直接地或者间接地实现Portlet接口。同时,也提供了一个叫GenericPortlet的基类,该类继承了Portlet接口,统一定义了可供 Portal 容器识别和调用的方法。因此,大部分情况下,开发人员只需要继承GenericPortlet这个基类,而不必直接实现Portlet接口。
Liferay Portal也是一个支持JSR168的企业门户,我们来看看在它的内部,是如何扩展GenericPortlet的。
1)      它自定义类LiferayPortlet扩展GenericPortlet,增加几个模式,如CONFIGEDIT_GUESTEDIT_DEFAULTPREVIEWPRINT.
2)      定义class StrutsPortlet,扩展LiferayPortlet,初始化模式参数,并定义了process action的过程。在liferay中,配置文件portlet-custom.xml中配置各portlet的一些,其中有个很重要的参数是portlet-class,该参数的值一般是com.liferay.portlet.StrutsPortlet,表明该portletstruts portlet.
3)      定义类JSPPortlet,扩展LiferayPortlet,该类在liferay中用不上,所以这边不做研究。简单提一下,如果参数portlet-class配置的值是JSPPortlet,那么该portletJSPPortlet
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;

		}

	}
可以清楚的知道,IFramePortlet定义自身所需要的default action,当portlet没有配置editActionviewAction的值时,在代码中赋予默认的值
下面图示了这个继承、扩展关系:

发表于 @ 2008年06月25日 21:52:00 | 评论( loading... ) | 编辑| 举报| 收藏

旧一篇:liferay使用技巧

  • 发表评论
  • 评论内容:
  •  
Copyright © chg2008
Powered by CSDN Blog