1.LifeRay的知识学习(越靠前推荐度越高):
- 国内某一对LifeRay较为详细的介绍,了解基本知识点非常有帮助,文章点此;
- 学习It,当然少不了国外的好书籍,这里推荐《Liferay User Interface Development》,对于开发lifeRay的模块很有指导作用,电子版请看附件(额,不知道如何上传);
- LifeRay的官方文档,排在最后,因为个人觉得质量一般,作为参考未尝不可。至于国内的《Liferay Portal 6.1门户网站建设最佳实践》一书,纯粹是翻译了官方的用户指南,对liferay开发帮助不大。
2.lifeRay与struts2的整合:
以下几点乃经验积累:
在portlet插件工程里整合strut2时,不要直接从strut2官网上下载的full版本,然后全部的jar包都放到插件工程的lib里面,否则将会有n多不应该出现的问题(说是不应该是因为这些问题都与lifeRay无关),时间证明,以下jar包可以支持整合开发:
<component name="libraryTable">
<library name="Struts 2-2.3.20" type="struts2">
<properties version="2.3.20" />
<CLASSES>
<root url="jar://$PROJECT_DIR$/lib/ognl.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/commons-fileupload.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/xwork-core.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/commons-lang.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/commons-io.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/asm-commons.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/asm-tree.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/asm.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/struts2-core.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/freemarker.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/javassist.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/struts2-portlet-plugin-2.3.20.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>
请注意strut2的版本为2.3.20。
成功编译打包插件工程(这里指portlet)后,并配置了某个mode的default页面(这里已view为例)如:
<init-param>
<name>defaultViewAction</name>
<value>index</value>
</init-param>
在页面上添加该portlet会报错说找不到action,借鉴常规web的方法,在WEB-INF路径下假设index.action即可,如图 :
当提交参数到action时,如果出现Reject process action for http://localhost:8080/xxx的error,在插件工程的liferay-portlet.xml里面,添加<add-default-resource>true</add-default-resource>配置即可,如图:
至于为何,请看:
<!--
If the add-default-resource value is set to false and the portlet does not
belong to the page but has been dynamically added, then the user will not have
permissions to view the portlet. If the add-default-resource value is set to
true, the default portlet resources and permissions are added to the page, and
the user can then view the portlet. This is useful (and necessary) for portlets
that need to be dynamically added to a page. However, to prevent security loop
holes, the default value is false.
The properties "portlet.add.default.resource.check.enabled" and
"portlet.add.default.resource.check.whitelist" in portal.properties allow
security checks to be configured around this behavior.
-->
<!ELEMENT add-default-resource (#PCDATA)>
发觉从页面提交上来的参数,在action里面找不到时,有如下几个解决办法:
1. In your JSP, add <portlet:namespace/> in front of parameters names.
2. use Alloy elements
3. In liferay-portlet.xml add below tag:<requires-namespaced-parameters>false</requires-namespaced-parameters>
以上办法,我只证实了第三种,确实可行,具体配置请看上图。
3.lifeRay的Two phases of Portlet Execution
The reason why two phases are needed is because a portlet does not own a whole HTML page, it only generates a fragment of it. The portal that holds the portlet is the one responsible for generating the page by invoking one or several portlets and adding some additional HTML around them。