<Portlet开发指南>第六章

、 Portlet Config

Portletconfig对象提供了portlet初始化时需要使用的信息,Portletconfig还提供了访问portlet context,default event namespace,public render parameter names,resource bundle。这些信息都是在portlet.xml中定义了。

初始化参数

可以通过PortletConfig接口的getInitParameterNames和getInitParameter方法从portlet.xml中获取初始化参数,代码如下

String initPara = this.getInitParameter("portlet286.initpara");

log.info(initPara);

Enumeration initParas = getInitParameterNames();

while (initParas.hasMoreElements()) {

initPara = initParas.nextElement().toString();

log.info(getInitParameter(initPara));

} log.info(this.getInitParameterNames().toString());

Portlet Resource Bundle

可以在portlet.xml或者在资源文件里面定义portlet标题、关键字等信息,这些信息用来在portlet展现的时候渲染portlet的title。比如在portle.xml里面

<portlet-info>

<title>PLT6ResourceBundlePortlet</title>

<short-title>PLT6ResourceBundlePortlet</short-title>

<keywords>PLT6ResourceBundlePortlet</keywords>

</portlet-info>

当然也可以在resource-bundle里面定义

<resource-bundle>

com.portlet286.plt6portlet.nl.PLT6ResourceBundlePortletResource

</resource-bundle>

我们一般建议在资源文件中定义,这样可以很好的适应国际化的需要。

在GenericPortlet类中定义的render方法使用PortletConfig对象引用的ResourceBundle对象来设置portlet的title

默认时间命名空间

可以通过PortletConfig接口的getDefaultNamespace方法从portlet.xml中获取默认的命名空间,在events 和 public render parameters中需要命名空间。

公告展现参数

可以通过PortletConfig接口的getPublicRenderParameterNames方法从portlet.xml中获取到此portlet支持的public render parameter。

发布时间

可以通过PortletConfig接口的getPublishingEventQNames方法从portlet.xml中获取到此portlet支持的publish event。

处理时间

使用PortletConfig接口的getProcessingEventQNames方法从portlet.xml中获取到此portlet支持的Process event

支持的国际化

使用PortletConfig接口的getSupportedLocales方法从portlet.xml中获取到此portlet支持的local(国际化)

支持的运行时选项

使用PortletConfig接口的getContainerRuntimeOptions方法从portlet.xml中获取到此portlet支持的portlet容器运行时。

posted on 2010-12-20 17:58  sealhui  阅读(1818)  评论(0编辑  收藏  举报