Porlet的类和接口

Portlet->PortletAdapter
PortletRequest(接口)
PortletResponse(接口)
PortletSession(接口)
Client
 
基本上新编写的Portlet都是要继承PortletAdapter。PortletAdapter基本上实现所有的接口和方法。与Portlet不同的是,它几乎复写了所有抽象函数。估计设计这样两个抽象类(Portlet和PortletAdapter)是为了不同层次上的继承来设计的。
 
PortletRequest,PortletResponse,PortletSession没有什么太多的文章,只要在Portlet中正确使用就行了,参考HttpServletRequest,HttpServletResponse。
 
Client的主要作用是用来探测客户端的类型。
 
PortletConfigPortletContext
其中PortletContext比较重要,下面摘录它的描述如下。
The PortletContext provides a mechanism for the portlet to access the services of the portlet container in which it is running. For example, the Context provides access to the PortletLog, servlet context parameters as well as any services hosted by the portal such as Credentials Vault, PersistentConnection and possibly other custom services. The parameters accessed by the PortletContext are the context parameters set in the web.xml. These parameters are common to Chapter 2. Portlet API 89 all portlets deployed in the same web.xml, regardless of their organization into various portlet applications. The PortletContext object is retrieved from the PortletConfig object。
看了描述基本上比较清楚了,唯一比较敢兴趣的是直接去引用呢,还是IBM自己设计了一套更合理的读取方式?
 
PortletSettingsPortletApplicationSettings看了让人觉得眼花,主要作用是读取和设置在portlet.xml中concrete-portlet元素和concrete-portlet-app元素的属性值。
 
PortletData(请注意它是一个不需要实例化,一个可以被用户共享,又可以被单独用来存储用户内容的对象)
It provides a quick, secure and effective method of attribute persistence with no JDBC code required.
 
下面的例子把它解释的比较清楚了。
For example, the HelloWorld portlet uses PortletData to persist the greeting String and the moniker the user wishes to be addressed by. The Administrator installs this portlet, grants edit permissions to the All Authenticated Users group and places it on the Welcome page. The Administrator chooses to edit the portlet and enters “hello there” as the greeting String and “admin” as the moniker. When user JohnSmith logs into the portal page and opens the welcome page, he sees the name admin and the greeting “hello there”. The administrator decides to change the greeting to “Greetings”. Since JohnSmith has not edited the PortletData, he continues to share the PortletData and sees the changes the admin has made. JohnSmith chooses to edit the PortletData to use his name instead of admin. Once he edits the PortletData, he has his own PortletData object. Changes he makes will be seen by no one else. Furthermore, he will no longer see any changes to the PortletData made by the administrator.
 
PortletLog,PortletException,PortletWindow,User,PortletURI,这些对象差不多从名字就可以判断他们的作用。
 

Listeners

这些listners用他们的例子来表示是最清楚的。
PortletTitleListener
public void doTitle(PortletRequest request, PortletResponse response) throws PortletException, IOException
{ PrintWriter out = response.getWriter();
String title = getPortletSettings().getTitle( request.getLocale(), request.getClient());
out.print(title + "(" + request.getMode() + ")");
}
PortletPageListener
public class AgendaPortlet extends PortletAdapter implements
PortletPageListener {
........
public void beginPage(PortletRequest request, PortletResponse response)
throws PortletException, IOException {
PrintWriter out = response.getWriter();
out.println("This page contains my agenda.");
}
public void endPage(PortletRequest request, PortletResponse response)
throws PortletException, IOException {
PrintWriter out = response.getWriter();
out.println("End of my agenda.");
}
}
WindowListener
public void windowMaximized(WindowEvent arg0) throws PortletException {
// Some action can be performed
}
public void windowMinimized(WindowEvent arg0) throws PortletException {
// Some action can be performed
}
public void windowRestored(WindowEvent arg0) throws PortletException {
// Some action can be performed
}
public void windowClosing(WindowEvent arg0) throws PortletException { }
public void windowClosed(WindowEvent arg0) throws PortletException { }
public void windowDetached(WindowEvent arg0) throws PortletException { }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值