|
|
描述
|
|
portlet.xml
|
portlet.xml
用来定义
Portlet
的诸如部署名称、初始化参数、支持模式、
resource bundle
等普通的初始化信息,包括:
portlet-name
、
display-name
、
portlet-class
、
init-param
、
expiration-cathe
、
supports
、
portlet-info
、
security-role-ref
等等。其正式的规范请参考:
http://java.sun.com/xml/ns/Portlet/Portlet-app_1_0.xsd
|
|
liferay-portlet.xml
| |
|
liferay-display.xml
|
定义
Portlet
默认的所属类别。
Liferay Portal
对
Portlet
实行按类别管理和划分用户权限。
|
|
<Context docBase="D:/
Tomcat5028/ liferay
" path="" reloadable="true">
<Resource
name="jdbc/LiferayPool" auth="Container"
type="javax.sql.DataSource" />
<ResourceParams name="jdbc/LiferayPool">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
XXX
(其他配置,此处略)
</ResourceParams>
</Context>
有关
Liferay
对连接池的引用,可以去
Portal.properties
配置文件中修改。默认此配置文件已经被打在了
liferay
的
portal-ejb.jar
中。
|
|
//
注意,暂时必须把liferay应用配置成为默认根应用,否则不可以正确运行。
<Context docBase="D:/ Tomcat5028/ liferay " path="" reloadable="true">
<Realm className="org.apache.catalina.realm.JAASRealm"
appName="PortalRealm"
userClassNames="com.liferay.portal.security.jaas.PortalPrincipal"
roleClassNames="com.liferay.portal.security.jaas.PortalRole"
debug="99"
useContextClassLoader="false" />
</Context>
|
|
PortalRealm
{
com.liferay.portal.shared.security.jaas.PortalLoginModule required;
};
|
|
包结构
|
说明
|
|
com.liferay.counter
|
主要提供主建操作服务,Liferay内部的提供的组织结构表维护,就是采用counter提供的主建自增机制
|
|
com.liferay.filters
|
提供一些基础的基于servlet filter的过滤器
|
|
com.liferay.taglib
|
提供最基本的web展示标签
|
|
com.liferay.util
|
提供最基本的一些公共组件
|
|
包结构
|
说明
|
|
com.liferay.portal
|
此包下放置了portal服务相关的一些异常
|
|
com.liferay.portal.action
|
负责一些struts action处理,比如Login等
|
|
com.liferay.portal.definitions
|
此包不是类包,而是负责放置一些定义相关的dtd文件资源。具体需要哪些dtd,可以参考com.liferay.portal.util. EntityResolver类
|
|
com.liferay.portal.dependencies
|
此包也不是类包,而是负责一些依赖性的资源文件。
|
|
com.liferay.portal.deploy
|
负责自动部署和热部署
|
|
com.liferay.portal.events
|
这个包内主要是一些行为处理类
|
|
com.liferay.portal.im
|
即时消息的支持
|
|
com.liferay.portal.jcr
|
提供JSR-170 JCR的支持,并内部提供Jackrabbit的实现支持
|
|
com.liferay.portal.job
|
对一些时间调度性Job的支持
|
|
com.liferay.portal.language
|
对语言的支持包
|
|
com.liferay.portal.lucene
|
对全文检索的支持
|
|
com.liferay.portal.model
|
一些模型对象的集合
|
|
com.liferay.portal.security
| |
|
com.liferay.portal.servlet
| |
|
com.liferay.portal.spring
| |
|
com.liferay.portal.struts
| |
|
com.liferay.portal.theme
|
提供对“主题”,也就是界面风格的支持
|
|
com.liferay.portal.tools
| |
|
com.liferay.portal.util
| |
|
com.liferay.portal.velocity
| |
|
com.liferay.portal.wsrp
|
|
包结构
|
说明
|
|
com.liferay.portlet
|
Liferay Portlet的一些基础类
|
|
com.liferay.portlet.admin
|
管理portlet
|
|
com.liferay.portlet.calendar
|
日期portlet虽然可以不需要,但是其内部提供对job的调度。
|
|
com.liferay.portlet.communities
|
这个是负责配置用户其所在的group,利用可以配置用户所拥有的工作区。
|
|
com.liferay.portlet.enterpriseadmin
| |
|
com.liferay.portlet.language
| |
|
com.liferay.portlet.layoutconfiguration
| |
|
com.liferay.portlet.login
| |
|
com.liferay.portlet.myaccount
|
用于配置用户信息
|
|
com.liferay.portlet.myplaces
|
用于控制用户的工作区选择
|
|
com.liferay.portlet.portletconfiguration
| |
|
com.liferay.portlet.themegallery
|
用于控制主题风格
|
|
com.liferay.portlet.translator
|
这个包必须要,虽然portlet可以不用,但是被portal.language包引入了
|
|
com.liferay.portlet.wsrp
|
这个包必须要。
|
|
位置
|
配置文件说明
|
|
/WEB-INF
|
portlet描述和struts等配置文件
|
|
/WEB-INF/classes
|
system.properties和portal.properties配置文件
|
|
/WEB-INF/classes/META-INF
|
portal-spring.xml,portal-hbm.xml,portal-log4j.xml配置文件。此位置可调,具体可以修改portal.properties内容。
|
Liferay额外研究(二): http://blog.youkuaiyun.com/james999/archive/2006/07/27/986386.aspx
Liferay额外研究(三):IFrame Portlet的session丢失问题解决
Liferay提供了一种非常的简单web应用整合和单点登陆的方式:Iframe Portlet。利用Iframe Portlet可以很容易将一个已经存在的web应用纳入,并且支持利用form的post或get方式,实现用户的登陆。
|
应用
|
位置
|
session id
|
|
(Liferay)
|
执行form post前
|
D03E1B828395EF5BCB1063A8290BD254
|
|
(APP_A)
|
Login操作
|
397BB3656E2A12A96CE3F16E0A89C607
|
|
(APP_A)
|
登陆后的新页面
|
58A1054C6EDE4A7D6CFA2FCDBB3E0736
|
|
ServletContext sc = getServletContext();
RequestDispatcher rd = null; rd = sc.getRequestDispatcher("/index.jsp"); rd.forward(request, response); |
|
response.sendRedirect(“
index.jsp
;jsessionid=397BB3656E2A12A96CE3F16E0A89C607”)
|
Liferay额外研究(二): http://blog.youkuaiyun.com/james999/archive/2006/07/27/986386.aspx
Liferay额外研究(三):http://blog.youkuaiyun.com/james999/archive/2006/08/08/1037326.aspx
Liferay在用户第一次登陆后,都会为其产生一个默认的私有首页Layout。 在Liferay早期版本,可以在系统管理员管理界面中,配置默认的group layout。但是在4.1版本中已经没有这个功能,所以默认情况下,新注册的用户,在登陆后,首先看到的其私有place都是一样的内容,而这些内容都是liferay提供的。
|
default.user.layout.group=User_Default
|
|
protected void
addDefaultLayouts(HttpServletRequest httpReq, User user)
throws PortalException, SystemException {
if (user.hasPrivateLayouts()) {
return;
}
(new LayoutCopy(user)).copyDefaultUserLayout(httpReq);
}
|
|
if (layoutsRequired) {
String user_layout_group = PropsUtil.get("default.user.layout.group");
if(user_layout_group==null || user_layout_group.length()==0){
addDefaultLayouts(user);
}else{
addDefaultLayouts(req, user);
}
}
|
时间:2006年9月3日晚
Liferay默认提供的基于 Struts Action扩展的PortletAction是不支持多分发命令的,也就是我们一般常用的DispatchAction。但在我们日常基于 Struts处理的操作中,已经大量的沿用了DispatchAction处理方式,采用“cmd=queryall”诸如此类的方式。
这样后续多分发 Action在书写的时候,只需要定义不同的方法即可,但是方法的参数需要依照如下规范,如下一个queryAll的方法:
PortletConfig config, RenderRequest req, RenderResponse res)
throws Exception {
// 业务处理
// 返回ActionForward即可
}
在那些portlet配置文件的view-action属性中,是不能够增加参数的,比如你不能够采用 /ext/reports/view_reports?cmd=queryAll这种方式。所以我们需要在扩展的Portlet中做一些拦截。
public class DispachStrutsPortlet extends StrutsPortlet {
public void doView(RenderRequest req, RenderResponse res)
throws IOException, PortletException {
// 注意我的命令参数是cmdx,而不是通常的cmd。
String cmd = req.getParameter( " cmdx " );
if (cmd == null || cmd.length() == 0 ){
if (req.getWindowState().equals(WindowState. MAXIMIZED)) {
req.setAttribute( " cmdx " , " queryAll " );
}
super .doView(req, res);
}
}
时间:2006年9月5日晚
(contentType.startsWith( " multipart/form-data " ))) {
req = new UploadServletRequest(req);
}
在UploadServletRequest类中,则将所有当前请求参数进行了提取,并对上传的文件做了临时存储。实际上内部是采用Apache Commons Upload进行的封装。
这样在PortletAction的procesAction处理中,可以对上传附件进行业务处理和存储。 当然,你可以通过ActionRequest来强制自己获取原始的UploadServletRequest对象,可以如下操作:
public void processAction(
ActionMapping mapping, ActionForm form, PortletConfig config,
ActionRequest req, ActionResponse res)
throws Exception {
// 注意这里面是获取UploadPortletRequest对象
UploadPortletRequest urequest = PortalUtil.getUploadPortletRequest(req);
File f = urequest.getFile( " file1 " );
}
ActionRequestImpl reqImpl = (ActionRequestImpl)req;
HttpServletRequest httpReq = reqImpl.getHttpServletRequest();
UploadServletRequest urequest = (UploadServletRequest)httpReq;
置于在Action处理阶段,获取到UploadServletRequest对象后存储附件、过滤附件类型等操作就很容易实现了,此处不再累赘叙述。
不过在附件上传中都会涉及到一个问题:控制附件上传的大小和类型。对于类型的控制,liferay没有提供任何控制和扩展实现机制,这个只能开发人员在外围自己实现。
PortletURL portletURL = renderResponse.createActionURL();
portletURL.setWindowState(WindowState.MAXIMIZED);
portletURL.setParameter( " struts_action " , " /venus/template/fileupload/FileUpoadAction " );
portletURL.setParameter( " cmdx " , " uploadfile " );
portletURL.setParameter( " cmd " , " add " );
%>
< form name = " testForm " method = " post "
action = " <%= portletURL.toString() %> "
enctype = " multipart/form-data " >
</ form >
在第四篇《Liferay Portal额外研究(4):修改用户登录后的默认布局和内容》中,我讲了修改用户登录首页布局的方案,此篇再给提供一种更简洁的处理方案。
在第四篇的方案,其实有些违背Liferay的扩展本意,Liferay提供了在外围配置的方式,来统一设置用户的第一次默认登陆首页。
在portal_ext.properties中通过修改相应参数来控制:
default .user.layout.name = Home
# Set the layout template id that matches an existing TPL.
default .user.layout.template.id = 2_columns_ii
# Set the layout ids for the column specified in the layout template.
default .user.layout.column - 1 = 82 , 23 , 61 , 65 ,
default .user.layout.column - 2 = 8 , 11 , 36 , 33 ,
default .user.layout.column - 3 =
default .user.layout.column - 4 =
# Enter either " 800x600 " or " 1024x768 " to set the layout resolution.
default .user.layout.resolution = 80 0x600
可以通过修改“default.user.layout.template.id”属性来控制页面的布局格式;通过修改“default.user.layout.column-X”的属性来控制不同列防止的portlet。
但如果为了更加符合一些商业性的需求,比如同一个Location的下的user默认布局相同,等等,这些则需要重载ServicePreAction类,重载 addDefaultLayouts 方法来实现,然后再在portal_ext.properties修改相应属性即可。
本文详细介绍了Liferay Portal的部署过程,包括在新Tomcat下的部署步骤及注意事项。此外,还探讨了如何对Liferay进行瘦身,去除不必要的组件以提高性能。文中还涉及了IFramePortlet的session丢失问题及其解决方案。
8457

被折叠的 条评论
为什么被折叠?



