liferay开发文档别人我来让大家下
Liferay6 开发 环境部署 Liferay6实例

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。
LIFERAY-HOOK 开发指南

LIFERAY HOOK 开发步骤备注:适用版本号完全相同的IDE,SDK,否则会报错。
一、Liferay提供hook的目的是减少二次开发的代码与liferay核心工程的耦合,通过hook我们主要可以主要做以下六件事情:1、覆盖事件处理程序:如程序启动事件(application.startup.events)、登录注销事件(login.events.pre、login.events.post)、session的创建销毁事件等。
2、语言包:比如对liferay的某些翻译不满意,需要自定义,则可以使用hook 覆盖liferay的语言包。
3、liferay工程的portlet JSP内容:比如想在顶部的top_bar里面添加内容、想修改liferay的用户编辑界面、想修改用户登录界面等等。
4、覆盖portal.properties里面的属性配置:可以在hook工程里面覆盖一些liferay的portal.properties 里面属性配置,但是请注意,在hook工程里面只能覆盖部分的属性设置。
不能覆盖的如果需要可以在root/WEB-INF/classes 里面添加 portal-ext.properties,这个同可以覆盖所有的。
5、覆盖liferay的services里面的方法,如UserLocalService、GroupLocalService、OrganizationLocalService等等。
6、Liferay的Model监听程序,比如user、group、blog等的创建、更新、查看;插件的部署;集群的消息传递等等监听程序。
二、创建一个HOOK 工程1、在liferay IDE中,New Liferay Project-->选择hook-->输入project Name,点击完成,即可创建一个hook工程。
2、在IDE的工具条中,选择New Liferay hook,选择我们要创建的hook类型,如下图:三、重写或者覆盖JSP 页面1、在liferay IDE中,New Liferay Project-->选择hook-->输入project Name,点击完成,即可创建一个hook工程。
Liferay组织管理和权限设置

Liferay组织管理和权限设置Portal组织管理和权限设置Portal用户架构User:用户,最基本的单位,用户可以加入到多个其它对象中,如组织单元,社区。
Organization:组织单元,以地域或其它组织方式来组织的一系列容器,可以有层级关系,比如我们的项目中的china,gd 等等。
Community:社区,由一系列相同爱好或其它有共性的用户来组成,比如fishing。
Role:角色,角色用来组织权限的,一系列拥有同样权限的用户可以拥有同样的角色,角色有下在三种:○Portal Roles系统角色○Organization Roles组织角色○Community Roles社区角色User Groups:用户组,用户组可以拥有组织角色和社区角色,可以看成Organization和Community的组合体。
e天下门户的组织架构这里标数字的都是组织单元,表示其层级关系。
页面构建1.组织单元的创建:组织单元管理在EnterPriseAdmin这个Portlet中。
这里我分别创建了三个组织单元,按照上面的层级关系。
编辑页面如下:实验证明中文组织单元名称也是可行的。
2.为组织单位管理页面在组织单拉后面的actions菜单后面单击选择Manage Pages.修改中国这个站的友好网址添加页面,如下图,好的习惯就是为每个站点添加一个管理页,url为admin管理页guest用户不能看3.页面定制权限设定刚才创建的站点只有portal管理员才有权限管理,包括内容发布,页面定制等,下面的动作是如何创建内容发布员。
这里的内容发布员,只有增加,删除等权限,没有审批权限,他发布的内容要内容审批员审批后才可以让用户看到。
1.创建用户:创建用户同样是用Enterprise Admin这个portlet。
点击Add User,增加用户这里的Screen Name不能是中文。
2.把用户加入到组织单元。
3.点击中国这个组织单元后面的actions后菜单中选择Assign Members。
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 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开发环境说明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

Liferay研究(一):初步在新Tomcat下部署从现在开始,会把我最近在研究的开源Portal Liferay一些心得贴出来。
研究Liferay版本:Liferay Professional 4.0.0柯自聪兄弟写过一系列的Liferay Portal开发文章,参考/ea moi/。
所以基础性内容,本文不再细说,可参考柯自聪的文章或Blog。
(一)部署Liferay PortletLiferay简单部署一个portlet并不是很复杂,通过WEB-INF目录下的portlet.xm l、liferay-portlet.xml、liferay-display.xml描述即可。
描述portlet.xml portlet.xml用来定义Portlet的诸如部署名称、初始化参数、支持模式、re source bundle等普通的初始化信息,包括:portlet-name、display-name、portlet-class、init-param、expiration-cathe、supports、portlet-info、security-role-ref 等等。
其正式的规范请参考:/xml/ns/Portlet/Portlet-app_1_0. xsdliferay-portlet.xml 定义Portlet默认可用的用户组、默认模板、是否支持多个实例等,规范由/dtd/liferay-Portlet-app_3_5_0.dtdliferay-display.xml 定义Portlet默认的所属类别。
Liferay Portal对Portlet实行按类别管理和划分用户权限。
Liferay是基于Struts Template页面模版技术来实现页面的,所以Liferay默认提供了com.liferay.portlet.StrutsPortlet这个Portlet Class来完成Portlet处理的;当然为了简单对普通jsp页面的处理,Liferay也提供了com.liferay.portlet.JSPPortlet等其他Portlet Class。
Liferay 使用手册

Liferay 使用手册
刘建军
os9@
1.快速入门
1.1. 安装
去liferay官方网站上下载liferay-portal-tomcat-4.2.2.zip,直接解压就可以,然后执行liferay-portal-tomcat-4.2.2\bin\startup.bat命令,显示liferay已经启动
1.2. 测试
在浏览器上输入:http://localhost:8080/
1.3. 登录
用户名:test@ 密码:
test
登录后界面如下:
1.4. 添加portlet
然后在左边出现如下画面,就可以选择自己想要的portlet 了。
从这里进入 添加portlet
2.高级使用
2.1. 增加新用户
从这里进入
保存就完成添加
用户建立后,在这里改密码在这里可以将用户添加到组织或区域中
喜欢中文?
这里改改就行
2.2. 给用户增加角色
第一步:进入角色标签页
先选中角色,
再点击分配第二步:找到要添加到adminstrator角色的用户
2.3. 增加组织
与添加用户类似2.4. 增加地域
与添加用户类似先点击可用的再更新关联关系
2.5. 变更主题
从这里进入
选你所爱。
Liferay 6开发指南

Liferay 6.0开发指南1. 介绍1、已有的应用集成方法:将应用重写为一个Portlet创建一个简单的Portlet整合应用(一般使用Web Service),可以使用iframe或http 代理(可以使用Liferay's WebProxy portlet)。
已有的应用要像部署门户插件一样,把WAR文件部署到应用服务器里,可以使用控制面板或直接复制的方式完成。
Liferay可以自动创建一个Portlet通过iframe集成已有应用。
2、自定义主题风格(Themes)3、自定义布局模板(Layout Templates)4、自定义或扩展门户功能:Hook plugins)Hook plugins可以用来扩展Liferay的核心功能。
5、高级扩展方式:Ext plugins扩展插件可以允许开发人员修改Liferay的核心部分,可以修改任何一个类。
扩展插件部署之后需要重新启动应用服务器。
Liferay 6.0之后用Ext plugins的开发方式替换了原来的Ext Environment开发方式,这样可以简化部署。
之前的扩展环境可以转换为一个独立的插件。
2. 插件开发工具包(THE PLUGINS SDK)2.1 安装Liferay1、下载Liferay Portal bundled with Tomcat;/downloads2、下载Plugins SDK;3、删除liferay-portal-[version]/tomcat-[tomcatversion]/webapps 除ROOT和tunnel-web目录的其他所有文件夹。
4、打开liferayportal-[version]/tomcat-[tomcat-version]/bin目录,运行startup.bat,启动Liferay。
5、http://localhost:8080,默认帐号/密码:test@/test。
6、设置环境变量ANT_HOME,将$ANT_HOME/bin加入到PATH环境变量中。
Liferay系列文章(六)Liferay应用之配制

Liferay系列文章(六)Liferay应用之配制Liferay Portal缺省只有一个系统管理员用户test,且以用户的电子邮件地址****************为登录用户名,密码是test。
Liferay Portal针对不同的用户会展现出不同的服务网页。
当浏览Portal主页网址时,自动转入网址web/guest/home调出面向所有人的Guest社区公共主页。
一个注册用户登录系统后,可以选择访问不同类型的Portal主页。
这也是Portal同传统网站所不同的地方。
以test用户登录Liferay Portal系统,鼠标移到右上角的“Welcome Test T est!”处调出菜单。
再把鼠标移到“我的地方”,可以看到test用户可以访问的Portal类型有“我的公共”,“T est Organization”,“Test Location”和“Guest”,且每一项又分为“公开页”和“私有页”。
其中“公开页”是其他人可以访问的网页,“私有页”则仅自己或注册用户且经过授权才可访问。
如“我的公共”中的“公开页”可以被所有人访问,而其“私有页”仅用户自己访问。
在每个Portal的主页中可以建立若干个网页,每个网页可以定义为不同的类型:Portlet,Panel,Embedded,Article,URL和Link to Page。
其中Portlet网页是最常用的一类。
在Portlet网页中,可以按照需要布置若干个Portlet插件。
每个Portlet插件实现不同的功能,在独立的小窗口中展现内容。
在Portlet窗口的右上角有5个图标,分别用来设置外观,配置功能属性,设置最小化或最大化显示,或者关闭Portlet窗口。
有权限的用户,可以添加、配置或删除Portlet。
系统的配置是由系统管理员实施的。
以test用户登录后,先进入“我的公共”私有页中,删除不需要的Portlet,只保留“语言”Portlet。
Liferay教程

<order by="asc">
<order-column name="name" case-sensitive="false" />
</order>
<!-- Finder methods -->
<finder name="CompanyId" return-type="Collection">
步骤:
1、建表
首先报表需要保存在数据库中,为报表建立报表数据库。根据liferay的开发过程,具体步骤如下:
(1) 在ext-impl文件夹下,新建service.xml
说明:该xml文件描述报表数据表的字段信息,并指定对应的java对象。
Xml代码
<?xml version="1.0"?>
<!-- PK fields -->
<column name="entryId" type="String" primary="true" />
<!-- Audit fields -->
<column name="companyId" type="String" />
说明:相关资料说这里的Class值经常会出错,请注意修改。
(3) Copy sql和报表对象,进行权限声明。根据liferay的开发过程,具体步骤如下:
(1) 在ext-impl文件夹下,新建resource-actions文件夹。
LifeRay培训讲义1-LifeRay基础

Portal简介 ----Portal的作用
一是针对跟人(网友)的应用。由于Portal的特色,企业 和网站可以很容易的将自己的服务进行标准封装,插入 Portal系统,提 供跟用户使用。现在很多门户网站和 专业网站有很多服务,但是很多服务用户根本就没有使 用过、发现过,通过Portal的形式给用户一个集中体验 的场所。 二 是针对企业,企业可以将现有的信息系统,资源通过 Portal来进行封装,提供给用户使用。比如:有些公司 有报销系统,考核系统,会议系统,但这些系统都 是彼 此分离的,使用和界面并不统一,通过Portal可以很容 易地将这些系统提供的服务封装并呈给用户使用。
20
Liferay简介 ----功能分类
Liferay具备健壮的功能体系,提供超过60多个 开箱即用的portlet ,主要分为三类:
• 门户、内容管理&WEB发布
• 协作应用(Collaboration)
• 社交应用(Social Networking)
21
Liferay简介 ----内容管理&WEB发 布
14
下图显示了Portal服务器、Portlet容器以及Portlet之间的关系。
15
Portal的组成 ---- Portal逻辑架构
Portal系统一般由Portal服 务器、支持Servlet的Java应 用服务器或Web服务器、数据 库服务器、LDAP服务器组成, 此外还可以加上身份认证和 访问控制服务器(Identity Server或Access Manager) 等。前面所说的Portlet容器 通常是打包在Portal服务器 中的。
Liferay简介 ----社交应用(Social Networking)
liferay-plugins-guide-4.3

L IFERAY P LUGIN D EVELOPMENT G UIDE Extending Liferay with Portlets and ThemesRichard L. Sezov, Jr.Liferay Plugin Development Guideby Richard L. Sezov, Jr.Portions reworked from the Themes document at /index.php/Themes. Please see the History tab there for author credit for this material.Copyright © 2007 by Liferay, Inc. All Rights Reserved.1. Introduction (5)W HAT IS A P ORTLET? (5)W HAT IS A T HEME? (6)2. Initial Setup (9)U SING THE P LUGINS SDK (12)3. Portlets (13)A NATOMY OF A P ORTLET P ROJECT (14)4. Themes (17)T HEME C ONCEPTS (17)A NATOMY OF A T HEME (18)J AVA S CRIPT (18)S ETTINGS (19)C OLOR S CHEMES (20)P ORTAL PREDEFINED SETTINGS (21)portlet-setup-show-borders-default (21)bullet-style-options (21)5. Deployment (23)C ONCLUSION (24)This guide is a quick start plugins development and deployment guide, using Liferay's Plugins Soft-ware Development Kit. Plugins (portlets and themes) are now the preferred way to add functionality to Liferay, as they have several benefits over using the extension environment:●Plugins can be composed of multiple smaller portlet and theme projects. This reduces the com-plexity of individual projects, allowing developers to more easily divide up project functionality●Plugins are completely separate from the Liferay core. Portlet plugins written to the JSR-168 stand-ard are deployable on any portlet container●Plugins can be hot deployed (i.e., deployed while the server is running) and are available immedi-ately. This prevents any server downtime for deploymentsThere are multiple ways to create portlet and theme plugins for Liferay. Many IDEs on the market today support portlet projects natively, and theme projects are nothing more than standard web modules with style sheets, images, and optional JavaScript and Velocity templates in them. Because of this, there are many tools which can be used to create plugins, from text editors to full blown integrated development en-vironments. If you are already familiar with such a tool, you may use that tool to create plugins.Because Liferay makes every effort to remain tool agnostic, we provide a Plugins Software Develop-ment Kit (SDK) which may be used to create both portlet and theme plugins. This SDK may be used with any text editor or IDE to create plugins for Liferay. Though it is not necessary to use this SDK to create plugins, it is the recommended method.This document will show you how to create both portlet and theme plugins using Liferay's plugin SDK. In the process, this will also show you the proper project layout for portlet and theme plugins, allow-ing you to use your own tools to create plugins if you wish to do so.What is a Portlet?Portlets are small web applications that run in a portion of a web page. The heart of any portal im-Introductionplementation is its portlets, because portlets are where the functionality of any portal resides. Liferay's core is a portlet container, and this container is only responsible for aggregating the set of portlets that are to appear on any particular page. This means that all of the features and functionality of your portal applic-ation must be in its portlets.Portlet applications, like servlet applications, have become a Java standard which various portal server vendors have implemented. The JSR-168 standard defines the portlet specification. A JSR-168 stand-ard portlet should be deployable on any JSR-168 portlet container. Portlets are placed on the page in a cer-tain order by the end user and are served up dynamically by the portal server. This means that certain “givens” that apply to servlet-based projects, such as control over URLs or access to the HttpServletRequest object, don’t apply in portlet projects, because the portal server generates these objects dynamically.Portal applications come generally in two flavors: 1) portlets can be written to provide small amounts of functionality and then aggregated by the portal server into a larger application, or 2) whole ap-plications can be written to reside in only one or a few portlet windows. The choice is up to those designing the application. The developer only has to worry about what happens inside of the portlet itself; the portal server handles building out the page as it is presented to the user.Most developers nowadays like to use certain frameworks to develop their applications, because those frameworks provide both functionality and structure to a project. For example, Struts enforces the Model-View-Controller design pattern and provides lots of functionality, such as custom tags and validating functionality, that make it easier for a developer to implement certain standard features. With Liferay, de-velopers are free to use all of the leading frameworks in the JavaEE space, including Struts, Spring, and Java Server Faces. This allows developers familiar with those frameworks to more easily implement portlets, and also facilitates the quick porting of an application using those frameworks over to a portlet implementa-tion.Additionally, Liferay allows for the consuming of PHP and Ruby applications as “portlets,” so you do not need to be a Java developer in order to take advantage of Liferay's built-in features (such as user management, communities, page building and content management). You can use the Plugins SDK to de-ploy your PHP or Ruby application as a portlet, and it will run seamlessly inside of Liferay. We have plenty of examples of this; to see them, check out the Plugins SDK from Liferay's public Subversion repository.What is a Theme?Themes are hot deployable plugins which can completely transform the look and feel of the portal. Theme creators can make themes to provide an interface that is unique to the site that the portal will serve. Themes make it possible to change the user interface so completely that it would be difficult or im-possible to tell that the site is running on Liferay.Liferay provides a well organized, modular structure to its themes. This allows the theme de-veloper to be able to quickly modify everything from the border around a portlet window to every object on the page, because all of the objects are easy to find. Additionally, theme developers do not have to custom-ize every aspect of their themes: if the plugin SDK is used, themes become only a list of differences from the6What is a Theme?Introduction default theme. This allows themes to be smaller and less cluttered with extraneous data that already exists in the default theme (such as graphics for emoticons for the message boards portlet).What is a Theme? 7Setting up the Plugins SDK is pretty straightforward. Download the archive from Liferay's Addition-al Files download page,in the section for developers here: /web/guest/downloads/additional. Unzip the file to the location in which you will be doing your work. You will see that it has the following directory structure:letsand theme plugin projects.maketheme projects in the plugins SDK requires that you have Ant 1.7.0or higher installed on your machine. Download the latest version ofAnt fromappropriate folder of your choosing.points to the folder to which you installed Ant. Use this variable toadd the binaries for Ant to your PATH by adding ANT_HOME/bin toyour PATH environment variable. Set another environment variablecalled ANT_OPTS with the proper memory settings for building pro-jects.file as follows (assuming you installed Ant inIllustration 1:Plugins SDK folderInitial SetupYou can do this on Windows by going to Start -> Control Panel, and double-clicking the System icon. Go to Advanced, and then click the Environment Variables button. Under System Variables, select New. Make the Variable Name ANT_HOME and the Variable Value the path to which you installed Ant (e.g., c:\java\apache-ant-1.7.0, and click OK.Select New again.Make the Variable Name ANT_OPTS and the Variable Value"-Xms256M -Xmx512M" and click OK.Scroll down until you find the PATH environment variable.Select it and select Edit.Add %ANT_HOME%\bin to the end or beginning of the Path. Select OK, and then select OK again. Open a com-mand prompt and type ant and press Enter. If you get a build file not found error, you have correctly in-stalled Ant. If not, check your environment variable settings and make sure they are pointing to the direct-ory to which you unzipped Ant.You will need a Liferay runtime on which to deploy your plugins to test them. We recommend us-ing the Liferay-Tomcat bundle which is available from Liferay's web site, as Tomcat is small, fast, and takes up less resources than most other containers. Download the latest Liferay-Tomcat bundle and unzip it to a folder on your machine. You can start Tomcat by navigating to the <Tomcat Home>/bin folder and running the startup command (i.e., startup.bat for Windows or ./startup.sh for Linux or Mac).You will notice that the plugins SDK contains a file called build.properties. Open this file in the text editor or IDE you will be using to create portlets and themes. At the top of the file is a message, “DO NOT EDIT THIS FILE.” This file contains the settings for where you have Liferay installed and where your deploy-ment folder is going to be, but you don't want to customize this file. Instead, create a new file in the same folder called ername.properties, where username is your user ID on your machine. For example, if your user name is jsmith (for John Smith), you would create a file called build.jsmith.properties.You will likely need to customize the following properties:10Initial SetupInitial Setup Illustration 2: The build.properties fileLiferay.auto.deploy.dir: This is the folder into which plugins should be placed in order for them tobe hot deployed to Liferay. By default, this folder is in $HOME/liferay/deploy.app.server.lib.portal.dir: This folder is where Liferay's libraries are installed. If you are us-ing the Liferay-Tomcat bundle,for example,you would set this to$ Initial Setup 11Initial Setup{app.server.dir}/webapps/ROOT/WEB-INF/lib.app.server.portal.dir: This folder is the folder to which Liferay is installed inside of your ap-plication server. For the Liferay-Tomcat bundle, set this to ${app.server.dir}/webapps/ROOT.piler: The default value for this is the Eclipse compiler, ECJ. ECJ is an alternate Javacompiler which performs very fast. If you do not have ECJ installed, the ant script will installit for you by copying ecj.jar to your Ant folder. If you do not wish to use ECJ to compile yourcode, you can set this to modern. This will cause the ant scripts in the plugins SDK to use thedefault Java compiler from your JDK.Save the file. You are now ready to start using the plugins SDK.Using the Plugins SDKThe plugins SDK can be used to house all of your portlet and theme projects enterprise-wide, or you can have separate plugins SDK projects for each of your portal projects. For example, if you have an in-ternal Intranet which uses Liferay and which has some custom written portlets for internal use, you could keep those portlets and themes in their own plugins SDK project in your source code repository. If you also have an external instance of Liferay running for your public Internet web site, you could have a separate plugins SDK with those projects (portlet and theme) in your source code repository. Or you could further separate your projects by having a different plugins SDK project for each portlet or theme project. It's really up to you.You could also use the plugins SDK as a simple cross-platform new project generator. You can gen-erate the project using the ant scripts in the plugins SDK and then copy the resulting project from the port-lets or themes folder to your IDE of choice. You would need to customize the ant script if you wish to do that, but this allows organizations which have strict standards for their Java projects to adhere to those stand-ards.12Using the Plugins SDKCreating portlets with the plugins SDK is a straightforward process. As noted before, there is a portlets folder inside of the plugins SDK folder. This is where your portlet projects will reside. To create a new portlet, first decide what its name is going to be. You need both a project name (without spaces) and a display name (which can have spaces). When you have decided on your portlet's name, you are ready to create the project. On Linux and Mac, from the portlets directory,enter the following command:type:portlets folder in your plugins SDK. This folder is your new portlet project. This is where you will be imple-menting your own functionality. At this point, if you wish, you can check your Plugins SDK into a source code repository in order to share your project with others.Alternatively, if you will not be using the Plugins SDK to house your portlet projects, you can copy your newly created portlet project into your IDE of choice and work with it there. If you do this, you may need to make sure the project references some .jar files from your Liferay installation, or you may get com-pile errors. Since the ant scripts in the Plugins SDK do this for you automatically, you don't get these errors when working with the Plugins SDK.To resolve the dependencies for portlet projects, see the class path entries in the build-common.xml file in the Plugins SDK project. You will be able to determine from the plugin.classpath and portal.classpath entries which .jar files are necessary to build your newly created portlet project.PortletsAnatomy of a Portlet Project1.Java Source2.Configuration files3.Client-side files (*.jsp, *.css, *.js, graphics, etc.)These files are stored in a standard directory structure whichdeploy ant task.The default portlet is configured as a standard JSR-168 portletIllustration 3:Portlet projectThe Java Source is stored in the docroot/WEB-INF/src folder. You necessary to implement your functionality.The Configuration Files are stored in the docroot/WEB-INF folder. The two standard JSR-168 port-let configuration files, web.xml and portlet.xml are here, as well as three Liferay-specific configuration files. These files are completely optional, but are important if your portlets are going to be deployed on a Liferay Portal server.liferay-display.xml: This file describes for Liferay what category the portlet should appear under in the Add Content window.liferay-portlet.xml: This file describes some optional Liferay-specific enhancements for JSR-168 port-lets that are installed on a Liferay Portal server. For example, you can set whether a portlet is instanceable, which means that you can place more than one instance on a page, and each portlet will have its own data. Please see the DTD for this file for further details, as there are too many settings to list here. The DTD may be found in the definitions folder in the Liferay source code.liferay-plugin-package.properties: This file describes the plugin to Liferay's hot deployer. One of the things that can be configured in this file is dependency .jars. If a portlet plugin has dependencies on partic-ular .jar files that already come with Liferay, you can specify them in this file and the hot deployer will modify the .war file on deployment so that those .jars are on the class path.Client Side Files are the .jsp, .css, and JavaScript files that you write to implement your portlet's user interface. These files should go in the docroot folder somewhere—either in the root of the folder or in a folder structure of their own. Remember that with portlets you are only dealing with a portion of the HTML document that is getting returned to the browser. Any HTML code you have in your client side files should14Anatomy of a Portlet ProjectPortletsbe free of global tags such as <html> or <head>.The default portlet project that is created is a simple JSR-168 portlet, with no bells and whistles. You can use this framework to write your code to the JSR-168 portlet API and implement all the functional-ity that you need. There are many portlets that are implemented this way. The standard portlet API is easy to use and straightforward.Many developers, however, prefer to use a particular framework when developing web applica-tions. Several frameworks, such as Struts, Spring, or Java Server Faces, make the development of web ap-plications more straightforward and easier to follow than a standard servlet implementation would be. All three of the frameworks mentioned can also be used to create portlets. Liferay has many examples of how these frameworks would be used in our public Subversion repository at SourceForge. You can grab them by checking them out of the repository or by accessing our Official Plugins page at /web/guest/downloads/official_plugins.You can also check out our Portlet Development Guide, which you can find in the same location you found this document. That guide gives you step-by-step instructions for creating portlets.Anatomy of a Portlet Project 15Creation of themes is done in a similar manner to the creation of portlets. There is a themes folder inside the plugins SDK where all new themes reside. To create a new theme, you run a command in this folder similar to the one you used to create a new portlet. For Linux and Mac, type:type:Theme ConceptsCustom themes are based on differences between the custom code and the default Liferay theme, called Classic. You will notice that there is a _diffs folder inside of your custom theme folder. This is where you will place your theme code. You only need to customize the parts of your theme that will differ from what is already displayed in the Classic theme. To do this, you mirror the directory structure of the Classic theme inside of the _diffs folder, placing only the folders and files you need to customize there.For example, to customize the Dock (a necessary component of all themes), you would copy just the dock.vm file from your Liferay installation(the Classic theme is in<Tomcat Home/webapps/ROOT/html/themes/classic) into your theme's _diffs/templates folder. You can then open this file and customize it to your liking. For example, you might want to change the welcome message to something else, like “Quick Links.”For custom styles, we recommend you create a css folder and place a single file there called custom-.css. This is where you would put all of your new styles and all of your overrides to the default Liferay styles.ThemesIt is best to do it this way because of the order in which the .css files are loaded. Custom.css is loaded last, and so anything inside this file will be guaranteed to override any styles that are in any of the other style sheets.Anatomy of a ThemeThe folders in themes are designed to be easy to navigate and understand. Currently, this is what the new directory structure looks like:/THEME_NAME//css/base.csscustom.cssmain.cssnavigation.cssforms.cssportlet.cssdeprecated.csstabs.csslayout.css/images/(many directories)/javascript/javascript.js/templates/dock.vmnavigation.vmportal_normal.vmportal_popup.vmportlet.vm/WEB-INF/META-INFtomize that portion of the theme.JavaScriptLiferay now includes the jQuery JavaScript library, and theme developers can include any plugins that jQuery supports. The $ variable, however, is not supported (for better compliance with different port-lets). Inside of the javascript.js file, you will find three different function calls, like this:jQuery(document).ready(function() {//Custom javascript goes here});Liferay.Portlet.ready(function(portletId, jQueryObj) {//Custom javascript goes here});jQuery(document).last(function() {//Custom javascript goes here});18JavaScriptThemes jQuery(document).ready(fn);When this gets passed a function (it can be a defined function, or an anonymous one like above), the function gets executed as soon as the HTML in the page has finished loading (minus any portlets loaded via ajax).Liferay.Portlet.ready(fn);When this gets passed a function (it can be a defined function, or an anonymous one like above), the function gets executed after each portlet has loaded. The function that gets executed receives two variables,portletId and jQueryObj.portletId is the id of the current portlet that has loaded, and jQueryObj is the jQuery object of the current portlet element.jQuery(document).last(fn);When this gets passed a function (it can be a defined function, or an anonymous one like above), the function gets executed after everything—including AJAX portlets—gets loaded onto the page.Besides theme-wide JavaScript there is also support for page specific JavaScript. The Page Settings form provides three separate JavaScript pieces that you can insert anywhere in your theme. Use the follow-ing to include the code from these settings:means that each field can only have one line of text. For multi-line scripts, the newlines should be escaped using \, just as in a normal .properties file.SettingsEach theme can define a set of settings to make it configurable.The settings are defined in the liferay-look-and-feel.xml using the following syntax:in the header. One of the themes has more details while the other is smaller (and takes less screen real es-tate). Instead of creating two different themes, we are going to create only one and use a setting to choose which header we want.While developing the theme we get to the header. In the portal_normal.vm template we write:Settings 19Themessame theme but have a different value for the header-type setting:<theme id="beauty1" name="Beauty 1"><root-path>/html/themes/beauty</root-path><templates-path>${root-path}/templates</templates-path><images-path>${root-path}/images</images-path><template-extension>vm</template-extension><settings><setting key="header-type" value="detailed" /></settings><color-scheme id="01" name="Blue"><css-class>blue</css-class><color-scheme-images-path>${images-path}/color_schemes/${css-class}</color-scheme-im-ages-path></color-scheme>...</theme><theme id="beauty2" name="Beauty 2"><root-path>/html/themes/beauty</root-path><templates-path>${root-path}/templates</templates-path><images-path>${root-path}/images</images-path><template-extension>vm</template-extension><settings><setting key="header-type" value="brief" /></settings><color-scheme id="01" name="Blue"><css-class>blue</css-class><color-scheme-images-path>${images-path}/color_schemes/${css-class}</color-scheme-im-ages-path></color-scheme>...</theme>Color SchemesColor schemes are specified using a CSS class name, with which you can not only change colors, but also choose different background images, different border colors, and so on.In your liferay-look-and-feel.xml (located in WEB-INF), you would specify the class names like so:<theme id="my_theme" name="My Theme"><root-path>/my_theme</root-path><templates-path>${root-path}/templates</templates-path><images-path>${root-path}/images</images-path><template-extension>vm</template-extension><color-scheme id="01" name="Blue"><css-class>blue</css-class><color-scheme-images-path>${images-path}/color_schemes/${css-class}</color-scheme-images-path></color-scheme><color-scheme id="02" name="Green"><css-class>green</css-class></color-scheme></theme>20Color SchemesThemes for each of your color schemes. In the case above, we would could either have just one called green.css and let the default styling handle the first color scheme, or you could have both blue.css and green.css.Now, inside of your custom.css, you would place the following lines:css styles like this:Portal predefined settingsThe portal defines some settings that allow the theme to determine certain behaviors. So far there are only two predefined settings but this number may grow in the future.portlet-setup-show-borders-defaultIf set to false, the portal will turn off borders by default for all the portlets.The default is true.Example:•liferay-portlet.xml•Portlet CSS popup settingbullet-style-optionsThe value must be a comma separated list of valid bullet styles to be used. The default is an empty list. The navigation portlet will not show any option in the portlet configuration screen.Example:this pattern:Portal predefined settings 21Themescase the bullet style option is cool:type of menu.For further information about themes, please see .22bullet-style-optionsYou will notice that when your project was created in the Plugins SDK, an ant script was also cre-ated for it. To deploy a plugin, you run the deploy ant task in your project. This task will compile your plu-gin (theme or portlet), store it in a dist folder, and deploy your plugin to your local Liferay installation.This is done by copying the plugin .war file to your Liferay hot deploy folder. If your local installa-tion of Liferay is running, your plugin will be automatically picked up by the server and deployed. Watch your Liferay console for messages. When you seeIf your plugin is a portlet, you can add it to a page by hovering over the Dock and clicking Add Con-tent. Find your portlet in the category you specified in your liferay-display.xml file. If you have not yet cus-tomized the file, your portlet will be in the Samples category. Simply click the Add button next to it to add it to the page you are currently viewing.If your Liferay installation is running in debug mode inside of your IDE, you can set breakpoints in your code and your debugger will stop the execution of the portlet in the specified place so you can step through the code. If you find a problem, fix the problem and then run the deploy ant task again to redeploy your portlet to the server for further testing.If your plugin is a theme, you can choose it for the page you are viewing by hovering over the Dock and clicking Page Settings. Go to the Look and Feel tab and your theme should be in the list. Select it and it will be applied to the page you are viewing. You can then click the Go back to full view link and see your theme applied to the full page.When you are finished implementing your features and debugging your code, create a final build for it by running the deploy ant task again. The plugin will reside in a dist folder in the project folder. You can then take the .war file stored there and deploy it to any running Liferay portal. All that is necessary for this is to copy the file into the hot deploy folder defined for the Liferay portal server. The file can also beDeploymentuploaded to a server housing a Liferay Software Catalog. Your portal administrator can then point the Plu-gin Installer portlet to this software catalog and through a simple point and click interface install any plu-gins that the development team makes available on their Software Catalog. For more information on how to configure this, please see the Liferay Administration Guide.ConclusionYou can see that the Plugins SDK provides a full development lifecycle for both portlet projects and theme projects. It is tool-agnostic, so developers are free to use the tools of their choice to create port-let projects and theme projects. It provides a method to create and deploy theme projects and portlet pro-jects with little effort and which supports the majority of application server platforms. And finally, it provides a structure to group the portlets and themes that go together with an overall portal project. We hope that you will enjoy using the Plugins SDK and that it will be a useful tool for you to create your port-lets and your themes.And remember, if you create open source portlets and themes, you can make them available on Liferay's community Software Catalog (/web/guest/community/community_plu-gins).Happy coding!24Conclusion。
liferay常用模块的简介

Liferay常用模块的简介Liferay中,常用的是CMS下面的模块,其中Journal,Journal Articles,Journal Content,Navigation等是比较常用的模块,下面就简要介绍这些模块。
(1)Journal Content模块:这是一个重要的子模块,通过这个模块,可以在页面上添加Articles,包括文字,图片等等,系统的很多内容的展示都是通过这个模块来实现的。
1)首先,在页面中加入一个Journal Content模块(一个页面中可以加入多个Journal Content模块),如下:2)配置Journal Content 的内容,点击Journal Content上的Configuration,页面显示如下:在页面上列出了所有的Articles列表,要在此Journal Content上显示某个Articles,则只需点击列表中的对应Articles就可以了,比如想要在这个Journal Content中显示welcome 这个Article,则点击welcome这个Article,页面上提示:Displaying Content 10317(10317是这个Article的id号),此时welcome这个Article就会显示在Journal Content上了,如下图所示:也可以点击按钮Add Article 添加Article,输入Article Name及Article的内容(一般是html代码),点击Save按钮就可以保存Article,点击Save and Continue保存已输入的内容并继续编辑Article ,点击Save and Approve 按钮可以保存Article并把此Article显示在Journal Content中。
Journal Content 的内容就介绍到这里,关于Journal Content的其他内容由用户需要时再自己体会。
liferay6plugin式开发

注:在按照这篇文档的操作前请先按照我上一篇的文档《liferay6.0 plug-in 安装说明》中所介绍的按照liferay plug -in 插件的方法把插件安装到eclipse 中.安装好了插件后我们就可以进行plug in到开发了。
1.首先我们要新建一个plug in 工程。
在eclipse 中点击创建plug in工程的图标。
然后选择其中的liferay portlet plug-in project.2.在创建新的plug-in project页面中填入project name,例如firstPortlet,然后liferay sdk,和liferay runtime 都选择默认的设置,也就是我们上一节里设置的。
Plug-in type 选择plortlet。
然后点击下一步。
3.在下一步中是要选择dynamic web module version 和configuration,这里都选择默认的设置,然后点击finish,这样eclipse会自动的帮我们进行编译工程。
(如果你如果在操作过程中出现什么错误的话,可以试试把dynamic web module version 选择为2.4 )编译完成后我们就可以看到编译了一个项目。
选择new liferay portlet选项。
5.在new liferay protlet 页面中输入portlet class 名称,和java package 名,然后点击next。
6,在设置Portlet部署描述符中指定的细节页面中,可以设置,portlet的名称,显示名称,标题,还有portlet 模式,liferay portlet模式,是否要创建jsp,jsp所在的文件夹6。
设置完portlet的基本信息后就进入了设置portlet页面信息的页面,这里可以设置页面所用的css 和js等。
设置完这些我们就一路点击next,最后点击finish就完成了整个设置的过程。
liferay配置

1. 关于LiferayLiferay 是一个完整的门户解决方案,基于J2EE的应用,使用了EJB以及JMS等技术,前台界面部分使用Struts MVC 框架,基于XML的portlet配置文件可以自由地动态扩展,使用了Web服务来支持一些远程信息的获取,使用Lucene实现全文检索功能。
(Lucene是一套用于全文检索和搜寻的开源程式库,由Apache软件基金会支持和提供。
Lucene提供了一个简单强大的应用程式接口,能够做全文索引和搜寻,在Java开发环境里Lucene是一个成熟的免费开放源代码工具;就其本身而论,Lucene是现在并且是这几年,最受欢迎的免费java资讯检索程式库。
人们经常提到资讯检索程式库,就像是搜寻引擎,但是不应该将资讯检索程式库与网搜索引擎相混淆。
)主要特点如下:1、提供单一登陆接口,多认证模式(LDAP或SQL);2、管理员能通过用户界面轻松管理用户,组,角色;3、用户可以根据需要定制个性化的门户布局;4、能够在主流的J2EE应用服务器上运行;5、支持主流的数据库;6、使用了第三方的开源项目,如Hibernate, Lucene, Struts;7、支持包括中文在内的多种语言;8、采用最先进的技术Java, EJB, JMS, SOAP, XML;9、提供扩展模式下开发;10、提供插件模式下开发;11、多数据库支持;这里我们就是利用Liferay源码通过Ant发布Liferay扩展包进行Portal项目的发布和开发工作。
2. 准备工作2.1 下载Liferay 5.2.3Liferay源码包 liferay-portal-src-5.2.3.zipOracle数据文件liferay-portal-sql-oracle-10-5.2.3.dmp(下载地址:/project/showfiles.php?group_id=49260)2.2 开发工具JDK 1.6 以上;Ant 1.7 以上;Tomcat 6.0 以上;Myeclipse 5.1以上;3. 环境配置3.1 JDK配置(1)JAVA_HOME:JDK的安装目录(2)PATH:把%JAVA_HOME%\bin目录加到path变量(检查JDK是否安装正确,通过“JAVA –version”命令来判断。
liferay介绍

门户功能简化的用户界面开发Nik Portal简化了局域网、外延网和Channel网站的开发,尤其是用户登录后可获得个性化服务、浏览权限的网站以及更新内容、整合/聚合多个现有服务时需要工作流审批流程的网站。
Nik Portal提供了一个单独的表示层,它将所有企业系统整合为一个易于终端用户使用的用户界面。
灵活的企业整合架构Nik Portal是一个中心的表示层平台,允许用户、管理员和开发人员从后台或传统应用程序整合内容、服务。
Nik支持多种整合方法,包括SOAP、REST、RSS及专有API’s。
即开即用工具集相比于市场上的其它Portal,Nik Portal 提供更多的即开即用Portlets——你可以从60多个Portlets中进行选择以自定义你的工作环境,其中包括可以提供网络发布、内容管理、协作与社交网络的Nik内容管理系统以及协作包。
安全的单点登录(SSO)从一点汇集并访问你的内容与应用程序。
Nik Portal能够将你所有不同的系统整合到一起,然后你只需通过一次安全的单点登录即可使用它们。
规则引擎集成通过Drools的高级个性化允许“情境个性化”,包括个性化的内容、功能以及基于用户方位、活动和其他自定义配置文件属性的功能。
社区&组织Nik用户能够被直观地组群到一个阶层的"组织"或跨组织的"社区"中,这能够使管理工作灵活化、简单化。
例如,不同地域的成员如美洲及欧洲可划分到"组织"里,但是,像销售、市场营销和工程学这些跨地域的学科就会创建为社区。
每个这样的组群也能够获取一个独立的小型门户,且拥有它们自己的一套页面、内容管理系统、共享的日程表以及授权。
一个用户可以属于多个组群,并轻松地在各个组群间穿梭。
用户个性化根据管理员的设置,用户可以通过添加、移除、定位内容或Portlet属性文件(例如,为天气Portlet编码)自定义Portal页面。
liferay技巧

Liferay 技巧1.根据自己需要修改liferay jedi主题选择jedi主题,具有下拉菜单,以下为修改部分:1、去除语言转换图,在liferay-jedi-theme\templates下的dock.vm文件中添加注释#* <div class="lang">$nguage()</div>*#2、去除右上角的导航下拉菜单,在文件dock.vm中#*<h2 class="user-greeting"><span>$user_greeting</span></h2>*#3、去除主菜单右上的/和my profile链接,在文件portal_normal.vm中#* <div id="top-menu"><a href="$company_url"></a>#if ($is_signed_in)| <ahref="$themeDisplay.getPathFriendlyURLPublic()/$user.getScreenName()/ profile">#language("my-profile")</a>#end</div>*#4、去除搜索输入窗,在文件portal_normal.vm#*#if ($group_id == $guestGroup.getGroupId())<div class="search">$theme.journalContentSearch()</div>#end#if ($update_available_url)<div class="popup-alert-notice"><a class="update-available" href="$update_available_url">#language ("updates-are-available-for-liferay")</a></div>#end*#5、左上角logo图标文件为custom/logo.png6、右上角下拉菜单我的帐户去除等#*#if ($show_my_account)<li class="my-account"><a href="$my_account_url">$my_account_text</a></li>#end*#7、去除公司logo链接,在文件portal_normal.vm<h1 class="logo">#* <a class="png" href="$company_url">$company_name</a>*#<a class="png">$company_name</a></h1>8、主菜单默认颜色为images\custom\下的bg.png9、ie上的ico图标在images\liferay.ico2.Liferay中如何让无权访问的Portlet隐藏?layout.show.portlet.access.denied=false未验证3.提高liferay性能转载自:/web/wanpeng/blog/-/blogs/777189提高liferay性能By Gavin Wan, On 5/7/08 6:28 AM似乎总能听到liferay性能的抱怨,在一个开源软件中这其实不难理解,就想一台公用的电脑,有人用oracle就在上面装个oracle,有人用DB2就又装了一个DB2…… 这些服务都启动自然就会慢。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
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<布局)类型地。
dvzfvkwMI1其中new Portlet 和Hook 地时候会得到liferay ide地帮助,即自动生成一些配置文件,而且这两种扩展地目录结构相同都能热部署,所以hook和portletrqyn14ZNXI可以合并起来开发,它们在相同地目录结构下能够只能够覆盖jsp页面,java类和配置文件也只能覆盖部分,而且它们跟ROOT是分开地war包.EmxvxOtOcoext扩展环境更加灵活!可以修改任何东西,但是ide不提供菜单方式,对于jsp页面可以在/docroot/WEB-INF/ext-web/docroot 目录下可以创建与源码中相同SixE2yXPq5目录结构即可覆盖.java类地目录则是创建工程地时候已经创建好地,例:ext下地/docroot/WEB-INF/ext-impl/src 目录对应源码中地/portal-impl/src目录.6ewMyirQFL如果我要修改源码中地LoginAction.java,那么我需要在/docroot/WEB-INF/ext-impl/src 目录中新建com.liferay.portlet.login.action包<和源码中包名相同).kavU42VRUs源码中地一些配置文件都在/portal-web/docroot/WEB-INF/下,在ext中对应在/docroot/WEB-INF/ext-web/docroot/WEB-INF/目录下.y6v3ALoS89三、plugin工程地部署.在liferay地根sdk目录中会发现build.properties配置文件,里面是一些关于配置web服务器地路径.M2ub6vSTnP将其复制一份,改名为build.${username}.properties,这里地username即计算机地用户,可以在命令行中查看C:\Documents and Settings\Administrator>,我地是build.Administrator.properties.0YujCfmUCw3、修改build.Administrator.properties中地app.server.dir,把它修改成你tomcat地路径.eUts8ZQVRd4、eclipse中配置刚才地sdk,然后new Liferay Plugin Project,,之后找到在根目录下地build.xml,直接执行direct-deploy即可. 此时到/tomcat/webapps 目录下会看到被部署过去地工程,部署其他类型地plugin也是如此.sQsAEJkW5T5、启动tomcat即可.四、配置文件之间地关系在开发liferay地时候肯定一些原有地portlet是需要修改地,但是怎么能从页面中看到地那个portlet一直找到源码中你想要修改java类和jsp页面呢?GMsIasNXkA根据一段时间地研究发现这个方法,但是看起来很笨.例如:我要修改登陆时用到地portlet和页面,我是这样找到地portlet和jsp页面地.1、在页面中“右键”--“查看源文件”,“Ctrl+F”搜索一下portlet地标题,即“sign in”.TIrRGchYzg2、找到之后会发现标题上面有段代码<section class="portlet" id="portlet_58“>,可以确定这个portlet地id 是47.7EqZcWLZNX3、上面地id对应源码中地liferay-display.xml中portlet 地id、对应portlet-custom.xml和liferay-portlet.xml中<portlet-name>标签地值.lzq7IGf02E4、找到portlet-custom.xml中对应地portlet后<init-param><name>view-action</name><value>/login/login</value></init-param>其中/login/login 即对应 struts-config.xml中<action>地path 属性值,从而可以找到其对应地java类.zvpgeqJ1hk5、<forward>地path属性值对应tiles-defs.xml中<definition>地name属性值,从而可以找到其对应地jsp页面.NrpoJac3v1ps:关于tiles与struts1地配置可以参考/view/25374.htm .1nowfTG4KI五、自定义布局 <layout)1、在liferay ide 出来之前自定义布局都是在tpl<freemarker)文件中直接写代码,现在直接用可视化工具就能画布局.fjnFLDa5Zo先new Liferay layout Template Plug-in Project ,打开生成地tpl文件可以用工具拖拽layout.tfnNhnE6e5对于它地使用没什么难地,部署则跟上面讲地一样.要么就在ROOT/layouttpl/custom中直新建tpl模板文件,之后在ROOT/WEB-INF/liferay-layout-templates.xml中配置.HbmVN777sL2、可以查看tpl中生成地代码与liferay自带地模板文件做对比,找找规律其实挺简单地.六、自定义主题<theme)liferay portal中每个页面都可以设置不同地theme,在ROOT/html/themes/目录中每个文件夹就代表一个theme,liferay默认地theme就是基于_styled地,不过这个theme中地样式只是提供给portlet地,而默认使用地主题是classic,打开_classic可以看到其目录结构如下.V7l4jRB8Hs这里地_diffs目录是自定义theme最主要地,除_diffs之外地目录都是theme所需地资源目录.如果你想要覆盖当前地theme地样式则可以在这个目录中创建与其他资源目录相同结构地目录、之后创建相同名字地文件就会覆盖.或者直接改资源目录里地css文件、.vm文件也都可以.83lcPA59W9自定义liferay地主题还是有两种方法,像自定义layout一样,一种是用liferay ide ,一种是直接在ROOT中改.mZkklkzaaP2、使用liferay ide自定义主题.首先New Liferay theme Plug-in Project,工程中会出现_diffs目录,这时需要从ROOT/html/theme/classic 中拷贝css、images、js、templates 目录到工程中与_diffs同级.现在等于拥有了跟classic一模一样地一套theme,如果想改动样式则在diffs 中改,这样比较好维护,官方开发指南中建议只改custom.css文件,因为所有样式都在这个文件里面,之后部署即可.AVktR43bpw3、直接在ROOT中自定义主题.在ROOT/html/theme/中直接拷贝classic一份并改名为mytheme,然后在WEB-INF目录中修改liferay-look-and-feel.xml,新增mytheme地配置信息即可,需要修改样式同2中地方式即可.ORjBnOwcEd4、关于页面中地布局、theme中地color schemes 、js 地修改可以参考官方开发指南,还需要了解velocity地语法.2MiJTy0dTT七、liferay提供地webserviceliferay对外提供地web service 地址http://localhost:8080/tunnel-web/axis ;如果有需要地话可以调用.gIiSpiue7A八、配置文件地属性portal.properties九、liferay portal debug源代码具体步骤如下:将liferay portal 源码导入eclipse编译,对着工程右键--》debug as--》debug configurations--》source选项卡--》点右边add--》选择java project--》选择liferay portal 源码地工程--》OK了.以dubug模式启动liferay自带地tomcat,在源码地MainServlet中设置断点,用户每一次请求都会经过其service方法,这样就能看到效果了.uEh0U1Yfmh----by liuyake。