Liferay6 开发 环境部署 Liferay6实例

合集下载

Liferay Portal 6学习笔记4

Liferay Portal 6学习笔记4

本篇主要介绍liferay的开发模式liferay推荐两种开发模式一、插件模式开发。

二、扩展环境开发。

插件模式开发在上一篇文章里面通过liferay ide建立的那个工程就是插件模式开发。

什么是插件模式开发呢?简单说就是提供一个独立的war包放到应用服务器里面,如果我们打开%tomcat_home%/webapps就会看至上一篇中建立的工程LiferayStudy-portlet,同时还看到许多其他的文件夹,如下:这些文件夹是liferay里面自带的一些插件包,如chat、google map等。

扩展环境开发Liferay 6以后的ext模式开发有了变动,在Liferay 6之前的版本中扩展环境叫做Extension Environment,从liferay 6以后这种模式叫做ext plugin。

(其实现在的开发模式可以称为一种了,都可以统称为插件开发,不过这两种模式有很大区别,还是分开来比较好)ext plugin(扩展插件)是以前使用Extension Enviroment(扩展环境)的升级版本,用来替代以前的ext开发模式。

现在的ext plugin开发可以称为一种轻量级的扩展环境,现在做扩展环境只需要使用不到10M大小liferay-plugins-sdk,而早期版本的开发要么需要自己下载Ext环境,要么需要自己从源代码里面编译一个扩展环境出来。

虽然现在的ext plugin使用的是不到10M大小的SDK,但是开发方法和运行原理和之前使用的Extension Enviroment是一样的。

看一下liferay ext plugin模式在Eclipse里面的工程目录在这里个工程里面我们写的java类文件一般在docroot/WEB-INF/ext-impl/src 目录下面,jsp文件一般在doroot/ext-web/docroot目录下面。

文件夹ext-impl、ext-lib、ext-service、ext-util-bridges 、ext-util-java、ext-util-taglib这些在部署的时候会被打成jar包,ext-web/dcroot对应的就是tomcat下面的root目录。

Liferay开发环境配置说明文档

Liferay开发环境配置说明文档

From Elias的个人主页Develop: Liferay开发环境配置说明文档(中国科学院研究生院网络中心)On this page... (hide)1. 文档说明2. 基本环境配置2.1 准备必须的软件,并进行环境参数配置2.2 下载LifeRay程序包2.3 安装和配置基本的Eclipse运行环境3. 基于Tomcat开发Portlet3.1 配置扩展开发环境3.2 添加插件支持3.3 配置数据库和执行Liferay3.4 完成一个最简单的JSP的Portlet4. 改进和调试Liferay自身代码4.1 安装Orion服务器4.2 在Eclipse中配置Orion4.3 修改Orion配置参数4.4 修改Liferay的配置文件4.5 向Orion上部署Liferay系统4.6 另一种调试Portlet组件的方法1. 文档说明本文基于Tomcat开发Portlet的部分根据LifeRay官方的Quick Start文档中“Writing a simple JSP Portlet”章节的内容试验精简而成,依据的文档版本是RC1,日期2006-06-15。

对Liferay自身代码的编译、调试环境则参考了原Liferay 3.6.1版本官方文档的“User Guide”对应章节。

因为本文档对说明文字进行了一些简化,以及官方文档有可能在您读到本文时又有更新,因此仍建议参考官方文档原文,以明确一些细节的意义。

但官方文档也存在一些错误,这里书写的内容对本文指明的各软件的特定版本号是已经试验成功的,因此也建议在读官方文档的时候同时参考本文。

按照本文的步骤完成后,能够建立一个在Windows下的Eclipse工具中开发兼容LifeRay的Portlet组件的基本环境,或者建立一个在Windows下的Eclipse工具对Liferay自身的源代码进行编译、调试、改进的环境。

按照你的需要,不一定要同时配置这两种环境,具体说明可参照对应章节开头的说明文字。

liferay开发文档别人我来让大家下

liferay开发文档别人我来让大家下

liferay开发文档别人我来让大家下部门: xxx时间: xxx制作人:xxx整理范文,仅供参考,可下载自行修改这个是别人地,但是是要收财富值地,哈哈,我来给大家免费纯属个人理解,不确保全部正确,仅供新手参考.一、Liferay地安装与使用目前liferay地最新版本是liferay portal 6.0.5,下载地址:/projects/lportal/ ;这里下载地是liferay与tomcat6绑定地版本,而且自带jdk1.6,下载完后需要做以下几个步骤便可轻松跑起来liferay了.1、下载完后最好找个文件夹专门用来做liferay地工作空间,因为以后好多文件下载,这样方便管理.首先解压liferay-portal-tomcat-6.0.5.zip,解压后其目录结构如下:b5E2RGbCAPliferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/data/目录下放是liferay自带地例子<7coogs)、数据库hsql地脚本及lucene产生地文档.liferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/tomcat-6.0.26/这个就是tomcat地home目录了,里面地结构和一般地tomcat是一样地,在webapps目录中放地就是liferay portal 地应用war包了,其中ROOT是最重要地,你会发现WEB-INF/classes中没有class文件,因为它们被打成jar包放在WEB-INF/lib下了,这样效果也一样.2、liferay中自带hsql数据库,如果你要改其他数据库地话可以在liferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/tomcat-6.0.26/webapps/ROOT/WEB-INF/classes下新建一个portal-ext.properties文件,内容如下(这里用mysql当作例子>: # # MySQL # jdbc.default.driverClassName=com.mysq l.jdbc.Driver jdbc.default.url=jdbc:mysql://localhos t/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false ername=roo t jdbc.default.password=1234其他数据库配置可以参见:/community/wiki/-/wiki/Main/Database+Portal+Properties上面地配置仅仅只是liferay 6.0 之后地方法,与之前地版本还是有不同地,具体地各版本地数据库配置可以参考:/community/wiki/-/wiki/Main/Database+Configuration3、在liferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/tomcat-6.0.26/bin 目录中执行startup.bat,此时就已经启动tomcat了,一般会启动5分钟左右.启动完毕后会自动在浏览器中打开http://localhost:8080,这样你就可以开始访问liferay portal 了.p1EanqFDPw4、登录liferay Portal在打开地浏览器中,点击右上角地login,输入帐号和密码.在这里地输入地帐号密码为email:bruno@password:brunoliferay从5.2之后地版本中都带有一个7cogs.inc公司地示例数据库,所以这里地管理员帐号密码如上.如果删除示例数据库,则账号密码如下:DXDiTa9E3demail:test@password:test5、删除7cogs例子a、在tomcat/webapps下面找到目录sevencogs-hook这个目录,删除掉b、在删除与tomcat平级地data/hsql目录c、重启tomcat,这时地管理员帐号就变为test@/test6、liferay启动地时候日志信息是乱码怎么办?打开liferay-portal-tomcat-6.0.5/liferay-portal-6.0.5/tomcat-6.0.26/conf/ 目录下地logging.properties文件,加上一句java.util.logging.ConsoleHandler.encoding = gbk ,重新启动就行了.RTCrpUDGiT二、搭建liferay地开发环境1、开发方式介绍从6.0 开始提供可eclipse可视化地插件之后就更加地友好,开发一个portlet或者一个hook都只需点点鼠标即可完成,这在官方wiki里面可以找到视频教程.在准备开发之前需要先了解“portlet规范”,然后再看liferay 6 地开发指南,之后再看下面地内容.5PCzVD7HxALiferay 6开发文档下载地址:/view/d8ab5bbd960590c69ec37682.htm ljLBHrnAILgPortlet 规范介绍文档下载地址:/view/e72aeefafab069dc50220181.htm lxHAQX74J0X首先需要下载liferay地sdk<开发环境包)、liferay ide<开发环境地插件).sdk地下载地址:/projects/lportal/files/LiferayPor tal/6.0.5/liferay-plugins-sdk-6.0.5.zip/downloadliferay ide下载地址:/projects/lportal/files/LiferayIDE /1.1.0/liferay-ide-eclipse-updatesite-1.1.0.zip/downloadLDAYtRyKfE安装此插件地时候eclipse要用3.6版本地.在自己地工作目录解压sdk包liferay-plugins-sdk-6.0.5.zip、在eclipse中安装liferay ide.解压sdk后看到其目录结构如下:有ext、hook、portlet等目录中放地是ext、hook、portlet以插件形式开发地文件.要修改一下sdk目录下build.properties文件中运行环境目录,此处使用tomcat,所以修改大约76行修改为类似下地目录地址:app.server.dir=D:/liferay/liferay-portal-6.0.3/tomcat-6.0.26以portlet为例子,里面有build.xml、build-common-portlet.xml、create.bat、create.sh、portlet.zip这5个文件,不用说build.xml、build-common-portlet.xml是ant文件应该都知道,create脚本就是新建一个插件工程,工程目录结构在portlet.zip中.但是现在有了liferay ide后就不用执行脚本创建了,而是直接用eclipse.Zzz6ZB2Ltk这里有liferay ide 地使用方法:/community/wiki/-/wiki/Main/Liferay+IDE+1.1+New+and+Noteworthy.在使用liferay ide地过程中需要配置sdk和与绑定tomcat地目录,这里就不做详细介绍了,就是路径地问题.装完ide后地图示:3、搭建完环境后新建一个liferay plugin project,可以new portlet、Hook<扩展环境)、ext<扩展环境)、theme<主题)、layout<布局)类型地。

Liferay Portlet指南(环境搭建)

Liferay Portlet指南(环境搭建)

Liferay Portlet指南(环境搭建)Liferay Portlet指南一、Liferay扩展环境搭建环境设置一、JDK 1.6.0, JDK 1.5.0 or JDK 1.4.2 1. 点击下一步安装2. 设置环境变量“JAVA_HOME”指向jikes的目录3. 增加“%JAVA_HOME%\\bin”到Path环境变量中二、Jikes 1.22 or Jikes 1.21 1. 解压缩安装包2. 设置环境变量“JIKES_HOME”指向jikes的目录3. 增加“%JIKES_HOME%\\bin”到Path环境变量中三、Ant 1.7.01. 解压缩安装包2. 设置环境变量“ANT_HOME”指向ant的目录3. 增加“%ANT _HOME%\\bin”到Path环境变量中配置扩展环境本指南所使用的liferay版本为4.2.2Step1:解压源代码将liferay源代码解压到任意目录,我们称之为${PORTAL_HOME}。

本指南中,将liferay源代码存放在目录${PORTAL_HOME}\\src下。

Step2:修改release配置文件在${PORTAL_HOME}\\src目录下找到文件release.properties,将其另存,命名为“release.${username}.properties”。

其中${username}就是当前Windows登陆的用户名,可以通过“开始菜单-》运行-》cmd.exe”后显示的默认路径看到,跟在“Documents and Settings”字样后面的就是当前登陆的用户名。

比如配置文件的名称是release.administrator.properties 。

文件的内容如下:修改lp.source.dir属性,来指定liferay源代码所在目录lp.source.dir=${PORTAL_HOME}/src修改lp.ext.dir属性,来指定liferay扩展环境放置目录lp.ext.dir=${PORTAL_HOME}/ext当然可以在源文件release.properties上修改,不过不建议这样做。

配置liferay开发环境配置说明

配置liferay开发环境配置说明

配置liferay开发环境说明1.准备文件(假设J2EE环境已配置好)ant部署工具:apache-ant-1.7.0-bin.zip(下面2中用)JIKES工具包:jikes-1.22-1.windows.zip(下面2中用)liferay原码包:liferay-portal-src-4.1.3.zip(下面2中用)liferay运行环境包:liferay-portal-tomcat-jdk5-4.1.3.zip(下面6中用)2.建立目录,并解压以上文件(1).在目录D:\liferay下建立目录文件夹ext和portal,apache-ant-1.7.0 jikes-1.22(2).将“ant部署工具”和“JIKES工具包”解到对应的apache-ant-1.7.0 jikes-1.22目录下(3).将原码文件liferay-portal-src-4.1.3.zip解到portal3.配置环境变量(1).ANT_HOME=D:\D:\liferay\apache-ant-1.7.0(2).JIKES_HOME=D:\liferay\jikes-1.22(3).Path=%JAVA_HOME%\bin;%JIKES_HOME%\bin;%ANT_HOME%\bin4.编译原码文件(1)在运行中用cmd进入D:\liferay\portal目录,执行ant start来编译原码(2)然后在此目录下建release.windows登录用户名.properties文件,并打开该文件写入lp.ext.dir=D:/liferay/ext设置信息后保存(3)然后在当前目录下执行命令:ant build-ext,此时在D:\liferay\ext 目录下生成文件5.进入D:\liferay\ext目录配置(1)将文件app.server.properties名称改为app.server.windows登录用户名.properties,并修改文件中的内容app.server.type=tomcat(2)将文件build.properties名称改为build.windows登录用户名.properties ,并修改内容jsp.precompile=on6.建立tomcat运行环境,并生成部署文件(1)将liferay-portal-tomcat-jdk5-4.1.3.zip运行包解压倒目录D:\liferay\ext\servers\tomcat下,准备好发布运行环境(2)在目录D:\liferay\ext\ext-web下执行ant(3)然后在D:\liferay\ext\ext-ejb下执行ant deploy,此时在该目录生成文件ext-ejb.jar包(4)将该ext-ejb.jar包拷贝到D:\liferay\ext\servers\ tomcat\ webapps\ROOT\WEB-INF\lib下,如存在就覆盖。

LifeRay Portal 6学习笔记6使用Struts2开发Portlet

LifeRay Portal 6学习笔记6使用Struts2开发Portlet

准备Liferay版本:6.0.4开发模式:普通插件模式(非Ext)Struts版本:2.1.8.1环境使用到的Struts2相关jar包如下:antlr-2.7.2.jarcommons-fileupload-1.2.1.jar freemarker-2.3.15.jarognl-2.7.3.jarstruts2-core-2.1.8.1.jarstruts2-portlet-plugin-2.1.8.1.jar xwork-core-2.1.6.jar工程目录如下:参考内容参考Struts2自带的portlet示例struts2-portlet-2.1.8.1.war,在Struts 解压包下面的apps目录里面,这个示例是基于Pluto(/pluto/)Apache的Portal实现,但开发的都是portlet,所以可以参考这个。

开发示例代码portlet.xmlXml代码1.<portlet>2.<portlet-name>StrutsPortlet</portlet-name>3.<display-name>Struts Test Portlet</display-name>4.5.<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>6.7. <!--这里的name名字不能修改,value对应于Struts.xml文件里面的配置-->8.<init-param>9.<name>viewNamespace</name>10. <value>/strutsDemoView</value>11. </init-param>12.13. <!-- 对应Struts.xml中设置的默认action -->14. <init-param>15. <name>defaultViewAction</name>16. <value>index</value>17. </init-param>18.19. <init-param>20. <name>editNamespace</name>21. <value>/strutsDemoEdit</value>22. </init-param>23.24. <init-param>25. <name>defaultEditAction</name>26. <value>index</value>27. </init-param>28.29. <expiration-cache>0</expiration-cache>30.31. <!-- 支持view、edit,和前面的portlet一样 -->32. <supports>33. <mime-type>text/html</mime-type>34. <portlet-mode>view</portlet-mode>35. <portlet-mode>edit</portlet-mode>36. </supports>37.38. <portlet-info>39. <title>My StrutsPortlet portlet</title>40. <short-title>SP</short-title>41. <keywords>struts,portlet</keywords>42. </portlet-info>43. </portlet>liferay-portlet.xmlXml代码1.<portlet>2.<portlet-name>StrutsPortlet</portlet-name>3.<instanceable>true</instanceable>4.</portlet>liferay-display.xmlXml代码1.<portlet id="StrutsPortlet"></portlet>Struts.xmlXml代码1.<?xml version="1.0"encoding="UTF-8"?>2.<!DOCTYPE struts PUBLIC3. "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"4. "/dtds/struts-2.0.dtd">5.6.<struts>7.<package name="strutsDemoView"namespace="/strutsDemoView"extends="struts-portlet-default">8.<action name="index"method="view"class="org.huqiwen.study.StrutsDemo">9.<result name="success">/strutsDemoView/view.jsp</result>10. </action>11. <action name="portletView"method="portletView"class="org.huqiwen.study.StrutsDemo">12. <result name="view">/strutsDemoView/viewMode.jsp</result>13. </action>14. </package>15.16.17. <package name="strutsDemoEdit"namespace="/strutsDemoEdit"extends="struts-portlet-default">18. <action name="index"method="edit"class="org.huqiwen.study.StrutsDemo">19. <result name="success">/strutsDemoEdit/edit.jsp</result>20. </action>21. <action name="portleEdit"method="portletEdit"class="org.huqiwen.study.StrutsDemo">22. <result name="edit">/strutsDemoEdit/editMode.jsp</result>23. </action>24. </package>25.</struts>java文件Java代码1.import com.opensymphony.xwork2.ActionSupport;2.3.public class StrutsDemo extends ActionSupport {4.5. private static final long serialVersionUID = 1L;6.7. private String message;8.9. public String getMessage(){10. return message;11. }12. public void setMessage(String message){13. this.message=message;14. }15. public String view() throws Exception {16. message = "hello Struts2 View Portlet!";17. return SUCCESS;18. }19. public String portletView(){20. return "view";21. }22. public String edit() throws Exception {23. message = "hello Struts2 Edit Portlet!";24. return SUCCESS;25. }26. public String portletEdit(){27. return "edit";28. }29.}strutsDemoView/view.jspHtml代码1.<%@ page contentType="text/html;charset=utf-8"%>2.<%@ taglib prefix="s"uri="/struts-tags"%>3.<h2><s:property value="message"/></h2>4.<s:form action="portletView!portletView.action"method="post"namespace="view">5.<s:textfield label="名字"key="message"></s:textfield>6.<s:submit value="提交"></s:submit>7.</s:form>其他的JSP不写了,和普通的Strtus2开发一样。

LiferayPortal6.0开发环境搭建

LiferayPortal6.0开发环境搭建

LiferayPortal6.0开发环境搭建
Liferay Portal 6.0开发环境搭建
2011-10-14 by 费利明开发工具
1.集成Liferay Portal IDE插件的Eclipse,在线插件安装地址:
/doc/5013765955.html
/tools/ide/eclipse/indigo/stable/
2.Liferay-plugins-sdk插件包,开发portlet、theme、layout、ext、hook等插件项目,下载
地址:/doc/5013765955.html
/zh/downloads/liferay-portal/available-releases
3.Liferay Portal RunTime Server,本环境使用Tomcat,官方有绑定好的,下载地址:/doc/5013765955.html
/zh/downloads/liferay-portal/available-releases
搭建步骤
1.打开集成Liferay Portal IDE的Eclipse
右键new项目有Liferay视图则插件安装成功
2.配置Liferay-plugins-sdk
3.配置Liferay Portal RunTime Server(new Server的时候配置也可以)
指向从官网下载的T omcat,做为运行时服务器
4.New一个Server,指向上面配置的RunTime Server,T omcat 右键new Server
5.启动Tomcat,浏览器访问http://localhost:8080,ok!
6.之后可以在Eclipse下开发各种Liferay Project插件项目了。

Liferay Portal6安装及简单设置

Liferay Portal6安装及简单设置

Liferay Portal 6学习笔记:Liferay Portal6安装及简单设置博客分类:Liferayportalliferay企业应用准备首先到/projects/lportal/files/Liferay%20Portal/6.0.3下载liferay-plugins-sdk-6.0.3.zipliferay-portal-sql-6.0.3.zipliferay-portal-src-6.0.3.zipliferay-portal-tomcat-6.0.3.zip安装Portal 6首先来安装一下Portal,先来第一眼看一下LifeRay是什么样子的。

1、解压liferay-portal-tomcat-6.0.3.zip这个文件是Liferay绑定到tomcat下的一个版本,可以直接拿来用的(此版本带有一个HSQL数据库,所以不用连接数据库,如如连接其他数据库会在后面讲到),解压之后进入到liferay-portal-6.0.3\tomcat-6.0.26\bin目录,点击startup.bat运行tomcat,待tomcat运行后在浏览器中输入http://localhost:8080即可进入看到liferay 6。

2、登录liferay Portal在打开的浏览器中,点击右上角的login,输入帐号和密码。

在这里的输入的帐号密码为email:bruno@password:brunoliferay从5.2之后的版本中都带有一个7cogs.inc公司的示例数据库,所以这里的管理员帐号密码如上。

如果删除示例数据库,则账号密码如下:email:test@password:test3、设置语言登录之后会发现,这里的Liferay是英文的,虽然这些英文也比较简单,但还是中文看着舒服。

点击左上角的Manager-control Panel进入到Liferay的控制面板。

我们首先设置当前用户的语言,点击左边最上面的My Account,然后在右边的Miscellaneous下面找到 Display Settings,点击他。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

Liferay6Development DocumentationTABLE OF CONTENTS1.PREFACE (2)W HAT'S COVERED (2)P REREQUISITE SOFTWARE (2)A SSUMPTION (3)2.LIFERAY INSTALLATION AND CONFIGURATION (3)D OWNLOAD (3)JDK1.6I NSTALLATION (3)M Y SQL I NSTALLATION (3)T OMCAT 6 INSTALLATION AND CONFIGURATION (4)3.LIFERAY 6 DEVELOPMENT ENVIRONMENT SETUP (6)4.DEVELOPING & DEPLOYING CUSTOM PORTLET TO LIFERAY 6 (10)L IFERAY EXTEND STRUCTURE ....................................................................... 错误!未定义书签。

C REATE A NEW EMPTY L IFERAY PROJECT (10)C REATE A NEW PORTLET (12)C OMPILING &D EPLOYING PORTLET (15)5.TABLE MAINTENANCE PORTLET DEVELOPMENT (15)6.FAQ(FREQUENT ASKED QUESTIONS) (35)7.APPENDIX (36)1.PrefaceThis guide was written as a quick reference to getting started developing on the Liferay Portal 6 platform (non-bundled) for Java developer step by step.What's coveredThe following list details all of the various parts of the documentation that are covered over the course of the tutorial.Preparation, development environment setupThe basic portlet development & deployment.Logic code with MySqlPrerequisite softwareThe following prerequisite software and environment setup is assumed. You should also be reasonably comfortable using the following technologies.Java SDK 1.5+Liferay Portal 6Eclipse 3.6Ant 1.7Apache Tomcat 6.0.14MySqlAssumptionMySQL is installed2.Liferay installation and configuration DownloadDownload Liferay 6 war & sdk file from websiteWar:/projects/lportal/files/Liferay%20Portal/6.0.5/liferay-portal-6.0.5.war/downloadDependency file:/projects/lportal/files/Liferay%20Portal/6.0.5/liferay-portal-dep endencies-6.0.5.zip/downloadSDK: /downloads/Tomcat 6: /download-60.cgi ()Now we have 4 files:apache-tomcat-6.0.20.zipliferay-portal-6.0.5.war,liferay-plugins-sdk-6.0.5.zipliferay-portal-dependencies-6.0.5.zipJDK 1.6 InstallationRefer to:/technetwork/java/javase/documentation/install-windows-15 2927.htmlMySQL InstallationRefer to:/doc/refman/5.1/en/windows-install-wizard.html Tomcat 6 installation and configuration1.Unpack apache-tomcat-6.0.20.zip to your prefer directory such asC:\java\tomcat60.From now on, we shall call this path as ${TOMCAT_HOME}.Notice: we are using non-install version.2.Create and edit ${TOMCAT_HOME}/conf/Catalina/localhost/ROOT.xml3.4.Make sure your database server is installed and is working. If it's installedin a different machine, make sure that it's accessible from the one where Liferay is being installed.5.Make sure the JDBC driver for your database is accessible by Tomcat. Wewill use MySQL as database, please copy connector-java-{$version}-bin.jar to ${TOMCAT_HOME}/lib/extDownload url:/downloads/mirror.php?id=13520#mirrors6.JNDI configure, editappropriate fields above.Notice:1)You need to create a file name portal-ext.properties, the following steps willtalk about this.2)Copy jta.jar/mysql-connector-java-x.x.xx-bin.jar to${TOMCAT_HOME}/lib/ext7.Create a mail session bound to mail/MailSession. Edit${TOMCAT_HOME}/conf/Catalina/localhost/ROOT.xml and configure8.9.10.Edit ${TOMCAT_HOME}/bin/catalina.bat that Tomcat can reference the11.Delete contents ${TOMCAT_HOME}/webapps/ROOT directory. Thisundeploys the default Tomcat home page.12.Unpack liferay-portal-6.0.5.war to ${TOMCAT_HOME}/webapps/ROOT.13.Create and edit14.For supporting UTF-8 URI Encoding, edit15.Run Tomcat,point browser to http://localhost:8080. You should see thedefault Liferay home page.3.Liferay 6 development environment setup1.Eclipse 3.6 installAfter you download eclipse-jee-helios-SR1-win32.zip, unzip it to yourprefer folder or some places like c:\java\eclipse, double click eclipse.exeyou will start eclipse.2.Change the encoding for you entire workspaceAfter start eclipse, go to Preferences>General>Workspace and select UTF-8 as the Text File Encoding. This should set the encoding for all the resources in yourworkspace. Any components you create from now on using the default encoding should all match.3.Unzip the Liferay SDK to your prefer directory such as C:\liferay.Go to C:\liferay\liferay-plugins-sdk-6.0.5, create a file namedbuild.{username}.properties({username} means the name of your computer)4.5.Download Liferay6 plugin SDKSRun eclipse , click Help -> Install New Software -> Available Software Sites -> Add /tools/ide/eclipse/helios/stableClick OK button6.Checked the “Liferay Tools” site from the selection box tree(About 10minutes)7.Click next and then click Finish to begin the installing (About 15 minutes).Eclipse will ask to restart when install completed, please restart it.8.Installing Liferay6 plug-in SDKClick Window -> Preferences -> Liferay,a)Clic k “Configure installed Liferay Plugin SDKs”, then click “Add” buttonChoose you Liferay SDK installed directory such as C:\liferay\liferay-plugins-sdk-6.0.5, click “OK” buttonb)Click “Create a new Liferay runtime environment”, choose “Liferay v6.0 CE (Tomcat 6)”Click next, finished the installing.c)Click “Create a new Liferay server”Click “Finish” button completed the installing.4.Developing & Deploying Custom Portlet to Liferay 6Create a new empty Liferay project1.Create a new Liferay projectClick File -> New -> Other -> Liferay -> Liferay Plug-in Project,Click next,Input your project name: myliferayand click”Ext” as plug-in type, click finish.Once you have created the project successfully, the following directories will auto created:2.Edit project propertiesYou can find a file named “portal-ext.properties” in path:/myliferay-ext/docroot/WEB-INF/ext-impl/srcb)For Auto creating predefine table and filling initial data: (just use for initial3.Create a empty Liferay6 schema by the “jdbc.default.url” in propertiese.g.: ecatalogue4.Create a new portlet1.2.Create a Java Action file in this path:File path:3.Create a JSP file4.Struts xml file setting5.Tiles xml setting6.Portlet-ext.xml settingFile path: /myliferay/docroot/WEB-INF/ext-web/docroot/WEB-INF/portlet-ext.xml <?xml version="1.0"?><portlet-app><portlet><portlet-name>product</portlet-name><display-name>product display name</display-name> <!-- No use for others --><portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class><init-param><name>view-action</name><value>/productportlet/demo</value></init-param><expiration-cache>0</expiration-cache><supports><mime-type>text/html</mime-type></supports><resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle> <security-role-ref><role-name>power-user</role-name></security-role-ref><security-role-ref><role-name>user</role-name></security-role-ref></portlet></portlet-app>7.Liferay-portlet-ext.xml setting8.Liferay-display.xml settingnguage-ext_en.properties settingFile path: /myliferay-ext/docroot/WEB-INF/ext-impl/src/content/Language-ext_en.propertiesCompiling & Deploying portletNow we can deploy the basic configuration, run ant to deploy/myliferay/build.xmlStart the tomcat server and open in browserhttp://localhost:8080/Notice: http://127.0.0.1:8080/ may not work in Firefox.5.Table Maintenance Portlet DevelopmentWe will create a table and coding in this part.1.Create example table in MySql2.Create product_service.xml to generate source codeFile path:/myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/product_service.3.Create build.xml for to run the product_service.xmlRun the build file auto generate source code under below path:/myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/model/impl/myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/service/base/myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/service/impl/myliferay/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/service/persistenceNotice:a)Please noted that path must be right, otherwise will not create successfully.b)Since this class is auto generated, you should never modify it, or your changes will beoverwritten the next time you run Service Builder. Instead, all custom code should be placedin XXXLocalServiceImpl.4.Add a method to the service layer.Add the following method to to ProductLocalServiceImpl.javaFile path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/service/impl/ ProductLocalServiceImpl.javapackage com.accentrix.ecatalog.product.service.impl;import java.util.List;import com.accentrix.ecatalog.product.model.Product;import com.accentrix.ecatalog.product.service.base.ProductLocalServiceBaseImpl;import com.liferay.portal.kernel.exception.SystemException;/*** @author tom.wu**/public class ProductLocalServiceImpl extends ProductLocalServiceBaseImpl {public List<Product> findByName(String name, int start, int end) throws SystemException {List<Product> list = productPersistence.findByName(name, start, end);return list;}public int countByName(ng.String name) throws SystemException {int count = productPersistence.countByName(name);return count;}}5.Add ProductSearch.java for search resultFile path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/ProductSearch.javaimport java.util.HashMap;import java.util.List;import java.util.Map;import javax.portlet.PortletRequest;import javax.portlet.PortletURL;import com.accentrix.ecatalog.product.model.Product;import com.liferay.portal.kernel.dao.search.SearchContainer;import com.liferay.portlet.enterpriseadmin.search.RoleDisplayTerms;/*** @author tom.wu**/public class ProductSearch extends SearchContainer<Product> {static List<String> headerNames = new ArrayList<String>();static Map<String, String> orderableHeaders = new HashMap<String, String>();static {headerNames.add("name");headerNames.add("qty");headerNames.add("comment");}public static final String EMPTY_RESULTS_MESSAGE = "no-products-were-found";public ProductSearch(PortletRequest portletRequest, PortletURL iteratorURL) {super(portletRequest, new RoleDisplayTerms(portletRequest), new ProductSearchTerms(portletRequest), DEFAULT_CUR_PARAM, DEFAULT_DELTA, iteratorURL, headerNames, EMPTY_RESULTS_MESSAGE);}}6.Create ProductSearchTerms.java for search term query.File path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/Productimport com.liferay.portal.kernel.dao.search.DAOParamUtil;import com.liferay.portal.kernel.dao.search.DisplayTerms;/*** @author tom.wu**/public class ProductSearchTerms extends DisplayTerms {public static final String NAME = "name";public String name;public ProductSearchTerms(PortletRequest portletRequest) {super(portletRequest);// name = ParamUtil.getString(portletRequest, NAME);name = DAOParamUtil.getLike(portletRequest, NAME);}public String getName() {return name;}public void setName(String name) { = name;}}7.Update ProductAction.java (already added in second part)File path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/Productimport javax.portlet.RenderResponse;import javax.portlet.WindowState;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import com.accentrix.ecatalog.product.model.Product;import com.accentrix.ecatalog.product.service.ProductLocalServiceUtil;import com.liferay.portal.kernel.dao.search.ResultRow;import com.liferay.portal.kernel.util.ParamUtil;import com.liferay.portal.struts.PortletAction;/*** @author tom.wu**/public class ProductAction extends PortletAction {public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig config, RenderRequest req, RenderResponse res) throws Exception {// search term,return all result if name is nullString name = ParamUtil.getString(req, "name");PortletURL portletURL = res.createRenderURL();portletURL.setWindowState(WindowState.MAXIMIZED);portletURL.setParameter("struts_action", "/productportlet/demo");portletURL.setParameter("name", name);// set table headerProductSearch searchContainer = new ProductSearch(req, portletURL);searchContainer.setDeltaConfigurable(false);ProductSearchTerms searchTerms = (ProductSearchTerms) searchContainer.getSearchTerms();List results = ProductLocalServiceUtil.findByName(searchTerms.getName(), searchContainer.getStart(), searchContainer.getEnd());int total = ProductLocalServiceUtil.countByName(searchTerms.getName());searchContainer.setTotal(total);searchContainer.setResults(results);List resultRows = searchContainer.getResultRows();req.setAttribute("searchContainer", searchContainer);for (int i = 0; i < results.size(); i++) {Product product = (Product) results.get(i);ResultRow row = new ResultRow(product, product.getUuid(), i);PortletURL rowURL = res.createRenderURL();rowURL.setWindowState(WindowState.MAXIMIZED);rowURL.setParameter("struts_action", "/productportlet/edit");rowURL.setParameter("redirect", searchContainer.getIteratorURL().toString());rowURL.setParameter("uuid", String.valueOf(product.getUuid()));String productName = product.getName();if (productName.length() > 10) {productName = productName.substring(0, 10) + "...";}row.addText(productName, rowURL);// namerow.addText(product.getQty() + "", rowURL);// qtyrow.addText(product.getComment(), rowURL);// commentresultRows.add(row);}if (getForward(req) != null && !getForward(req).equals("")) {return mapping.findForward(getForward(req));} else {return mapping.findForward("products");}}}8.Update products.jspFile path:/myliferay-ext/docroot/WEB-INF/ext-web/docroot/html/portlet/product/products.jsp</portlet:renderURL><aui:form action="<%= searchURL %>" method="post" name="productForm" onSubmit='<%= renderResponse.getNamespace() + "search();" %>'><aui:input name="productUuids" type="hidden" /><!-- for delete function --><aui:fieldset><aui:input inlineField="true" label="Name:" name="name" size="30" value="<%=name%>" /><aui:input align="absmiddle" border="0" inlineField="true" label="" name="search" src='<%= themeDisplay.getPathThemeImages() + "/common/search.png" %>' title="search" type="image" /></aui:fieldset><aui:button-row><aui:button type="submit" value="search" /><aui:button onClick='<%= renderResponse.getNamespace() + "addProduct();" %>' type="button"value='<%= LanguageUtil.format(pageContext, "Add Product", company.getName(), false) %>' /></aui:button-row><div class="separator"></div><liferay-ui:search-iterator searchContainer="${searchContainer}" paginate="<%= false %>" /><liferay-ui:search-paginator searchContainer="<%= searchContainer %>" /></aui:form></div><aui:script>function <portlet:namespace />addProduct() {document.<portlet:namespace/>productForm.action="<portlet:actionURLwindowState="<%=WindowState.MAXIMIZED.toString()%>"><portlet:param name="redirect" value="<%= currentURL %>" /><portlet:param name="struts_action" value="/productportlet/add" /></portlet:actionURL>";document.<portlet:namespace />productForm.submit();}function <portlet:namespace />search() {document.<portlet:namespace />productForm.submit();}</aui:script>Okay, the search function finished.9.Add ProductAddAction.javaFile path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/Product AddAction.java*/package com.accentrix.ecatalog.product.action;import javax.portlet.PortletConfig;import javax.portlet.RenderRequest;import javax.portlet.RenderResponse;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import com.liferay.portal.struts.PortletAction;/*** @author tom.wu**/public class ProductAddAction extends PortletAction {public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig config, RenderRequest req, RenderResponse res) throws Exception {return mapping.findForward("product.add");}}10.Update struts-config-ext.xml11.Update tiles-defs-ext.xml12.Add product_add.jspFile path:/myliferay-ext/docroot/WEB-INF/ext-web/docroot/html/portlet/product/product_add.jsp13.Save productFile path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/Product SaveAction.java/****/package com.accentrix.ecatalog.product.action;import javax.portlet.ActionRequest;import javax.portlet.ActionResponse;import javax.portlet.PortletConfig;import javax.portlet.PortletRequest;import javax.portlet.WindowState;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import com.accentrix.ecatalog.product.model.Product;import com.accentrix.ecatalog.product.model.impl.ProductImpl;import com.accentrix.ecatalog.product.service.ProductLocalServiceUtil;import com.liferay.portal.kernel.servlet.SessionErrors;import com.liferay.portal.struts.PortletAction;import com.liferay.portal.theme.ThemeDisplay;import com.liferay.portal.util.WebKeys;import com.liferay.portlet.ActionRequestImpl;import com.liferay.portlet.PortletURLImpl;/*** @author tom.wu**/public class ProductSaveAction extends PortletAction {@Overridepublic void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {try {// If you need validation,add the checking code here.// if (1 == 1) {// throw new Exception("............");// }Form fm = (Form) form;Product product = new ProductImpl();product.setName(fm.getName());product.setQty(fm.getQty());product.setComment(fm.getComment());ProductLocalServiceUtil.addProduct(product);} catch (Exception e) {SessionErrors.add(actionRequest, e.getClass().getName());setForward(actionRequest, "product.error");return;// required,otherwise will continue to next line}String url = this.getRedirctURL(portletConfig, actionRequest);super.sendRedirect(actionRequest, actionResponse, url);}protected String getRedirctURL(PortletConfig portletConfig, ActionRequest actionRequest) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);PortletURLImpl portletURL = new PortletURLImpl((ActionRequestImpl) actionRequest, portletConfig.getPortletName(), themeDisplay.getPlid(), PortletRequest.RENDER_PHASE);portletURL.setWindowState(WindowState.MAXIMIZED);portletURL.setParameter("struts_action", "/productportlet/demo");return portletURL.toString();}public static class Form extends ActionForm {private String uuid;private String name; // product nameprivate int qty;private String comment;public String getUuid() {return uuid;}public void setUuid(String uuid) {this.uuid = uuid;}public String getName() {return name;}public void setName(String name) { = name;}public int getQty() {return qty;}public void setQty(int qty) {this.qty = qty;}public String getComment() {return comment;}public void setComment(String comment) {ment = comment;}}}Deploy & restart server, we can test the add product function.14.Add ProductEditAction.javaFile path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/ProductEditAction.java/****/package com.accentrix.ecatalog.product.action;import javax.portlet.PortletConfig;import javax.portlet.RenderRequest;import javax.portlet.RenderResponse;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionForward;import org.apache.struts.action.ActionMapping;import com.accentrix.ecatalog.product.model.Product;import com.accentrix.ecatalog.product.service.ProductLocalServiceUtil;import com.liferay.portal.kernel.util.ParamUtil;import com.liferay.portal.struts.PortletAction;/*** @author tom.wu**/public class ProductEditAction extends PortletAction {public ActionForward render(ActionMapping mapping, ActionForm form, PortletConfig config, RenderRequest req, RenderResponse res) throws Exception {String uuid = ParamUtil.getString(req, "uuid");// productif (uuid != null) {Product product = ProductLocalServiceUtil.getProduct(uuid);req.setAttribute("product", product);}return mapping.findForward("product.edit");}}15.Add product edit JSPFile path:/myliferay-ext/docroot/WEB-INF/ext-web/docroot/html/portlet/product/product_edit.jspProduct product = (Product) request.getAttribute("product");%><portlet:actionURL var="saveURL"><portlet:param name="struts_action" value="/productportlet/update" /></portlet:actionURL><aui:form action="<%= saveURL %>" method="post" name="productForm" onSubmit='<%= "event.preventDefault(); " + renderResponse.getNamespace() + "updateProduct();" %>'><aui:input name="redirect" type="hidden" value="<%= redirect %>" /><aui:input name="uuid" type="hidden" value="<%=product.getUuid()%>" /><liferay-ui:error exception="<%= Exception.class %>" message="exception testing..." /><aui:fieldset><aui:input name="name" label="Name:" value="<%=product.getName()%>" size="40"/><aui:input name="qty" label="Qty:" value="<%=product.getQty()%>" size="10"/><aui:input name="comment" label="Comment:" value="<%=product.getComment()%>" size="80"/> </aui:fieldset><aui:button-row><aui:button type="submit" /><aui:button onClick="<%= redirect %>" type="cancel" /></aui:button-row></aui:form><aui:script>function <portlet:namespace />updateProduct() {submitForm(document.<portlet:namespace />productForm);}</aui:script>16.Add ProductUpdate.javaFile path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/Product UpdateAction.javaimport javax.portlet.PortletConfig;import javax.portlet.PortletRequest;import javax.portlet.WindowState;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import com.accentrix.ecatalog.product.action.ProductSaveAction.Form;import com.accentrix.ecatalog.product.model.Product;import com.accentrix.ecatalog.product.model.impl.ProductImpl;import com.accentrix.ecatalog.product.service.ProductLocalServiceUtil;import com.liferay.portal.kernel.util.ParamUtil;import com.liferay.portal.struts.PortletAction;import com.liferay.portal.theme.ThemeDisplay;import com.liferay.portal.util.WebKeys;import com.liferay.portlet.ActionRequestImpl;import com.liferay.portlet.PortletURLImpl;/*** @author tom.wu**/public class ProductUpdateAction extends PortletAction {@Overridepublic void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {Form fm = (Form) form;Product product = new ProductImpl();product.setUuid(fm.getUuid());product.setName(fm.getName());product.setQty(fm.getQty());product.setComment(fm.getComment());ProductLocalServiceUtil.updateProduct(product);String url = this.getRedirctURL(portletConfig, actionRequest, fm.getUuid());super.sendRedirect(actionRequest, actionResponse, url);}protected String getRedirctURL(PortletConfig portletConfig, ActionRequest actionRequest, String uuid) throws Exception {String redirect = ParamUtil.getString(actionRequest, "redirect");ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);PortletURLImpl portletURL = new PortletURLImpl((ActionRequestImpl) actionRequest,17.Update struts-config-ext.xmlFile path: /myliferay-ext/docroot/WEB-INF/ext-web/docroot/WEB-INF/struts-config-ext.xml<?xml version="1.0"?><!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN""/struts/dtds/struts-config_1_2.dtd"><struts-config><form-beans><form-bean name="productForm" type="com.accentrix.ecatalog.product.action.ProductSaveAction$Form" /></form-beans><action-mappings><action path="/productportlet/demo" type="com.accentrix.ecatalog.product.action.ProductAction" scope="request" ><forward name="products" path="products" /><forward name="product.success" path="product.success" /><forward name="product.err" path="product.err" /></action><action path="/productportlet/add" type="com.accentrix.ecatalog.product.action.ProductAddAction" scope="request"><forward name="product.add" path="product.add" /></action><action path="/productportlet/save" type="com.accentrix.ecatalog.product.action.ProductSaveAction" scope="request" name="productForm"> <forward name="product.error" path="product.add" /></action><action path="/productportlet/edit" type="com.accentrix.ecatalog.product.action.ProductEditAction" scope="request" ><forward name="product.edit" path="product.edit" /></action><action path="/productportlet/update" type="com.accentrix.ecatalog.product.action.ProductUpdateAction" scope="request" name="productForm"/> </action-mappings></struts-config>18.Add ProductDeleteAction.javaFile path:/myliferay-ext/docroot/WEB-INF/ext-impl/src/com/accentrix/ecatalog/product/action/Product。

相关文档
最新文档