1、Liferay Portal 1 Liferay Portal 2 Liferay Portal .5 Liferay Portal .6 .6 P or t al .6 1.1.1 JSR168 .6 1.1.2 WSRP.6 Portal .7 1.2.1 Portal .7 1.2.2 Portlet .7 Portlet .8 1.3.1 Portlet.8 1.3.2 Portlet Servlet .8 1.3.3 Portlet .9 Liferay Portal .9 1.4.1 Portlet .10 1.4.2 Portal .11 .13 Liferay Portal .
2、13 Liferay Portal .14 2.2.1 .14 2.2.2 .15 2.2.3 .15 2.2.4 .18 2.2.5 .19 2.2.6 .19 2.2.7 .20 2.2.8 .21 2.2.9 .21 2.2.10 Portlet .22 Liferay Portal .24 2.3.1 .24 2.3.2 .26 2.3.3 Portlet .27 2.3.4 .28 Liferay Portal .28 2.4.1 .28 2.4.2 .29 Liferay Portal .29 2.5.1 .30 2.5.2 Portlet Portal .30 2.5.3 .30
3、 Liferay Portal .31 32.6.1 web.xml.31 Liferay Portal 2.6.2 portlet.xml .32 2.6.3 liferay-Portlet.xml .33 2.6.4 liferay-display.xml .34 2.6.5 liferay-layout-templates.xml .35 2.6.7 liferay-look-and-feel.xml .35 Liferay Portal .36 .36 GenericPortlet.36 P or t let .37 3.2.1 defineObjects .37 3.2.2 rend
4、erURL .37 3.2.3 actionURL .38 3.2.4 param .38 3.2.5 namespace .38 P or t al .38 3.3.1 Request .39 3.3.2 Response .40 3.3.3 PortletConfig .41 3.3.4 Session .41 3.3.5 Preference .43 Portlet .44 3.4.1 .44 3.4.2 .44 3.4.3 HelloWorldPortlet .45 3.4.4 HelloJSPPortlet .46 Web .48 Liferay Portal .49 Liferay
5、 Portal .53 .53 .53 Ant .54 Liferay Portal .54 Java Web Portlet .55 .57 .57 .57 .57 .58 .58 4 Liferay Portal Portal Portal Portal MyNestcape MyYahoo MSN-Space Portal Liferay Portal Portal Hibernate Struts Spring JCP JSR168 Portal Portal 5 Liferay Portal Portal Liferay Portal Liferay Portal Portlet L
6、iferay Portal Liferay Portal Liferay Portal Portal P or t al P or t let Portal Liferay Portal Portal Liferay Portal P or t al Portal Portal Portal IBM BEA MicroSoft SAP Apache 1.1.1 JSR168 JCP JSR168(Java Specification Request) Portlet Specification V1.0 Portal Portlet Portlet JSR168 JSR168 Portal J
7、SR168 Portal Portlet 1.1.2 WSRP WSRP OASIS Web Service for Remote Portlet WSRP Web Service Portal Portal WSRP Portal Portlet Portlet WSRP HTML XHTML Web Service 6 Portal Liferay Portal Portal 1.2.1 Portal LDAP OA OA 1.2.2 Portlet 7 Liferay Portal Portlet Servlet Portlet 1.3.1 Portlet 1.3.2 Portlet S
8、ervlet 8 Liferay Portal 1.3.3 Portlet Portlet Portlet Portlet :Portlet Portlet Portlet Portlet Portlet Portlet Portlet Portlet :Portlet Portlet Portlet Portlet Portlet Portlet init Portlet PortletConfig Resource Bundle : Portlet Portlet UnavailableException PortletException Portlet Portlet Portlet P
9、ortlet destory Portlet Portlet UnavailableException Portlet Portlet Runtime Exception PortletException Liferay Portal 9 Liferay Portal 1.4.1 Portlet Portlet Portlet Portlet Portlet 10Portlet Liferay Portal Portlet 1.4.2 Portal Portlet A Portlet B Portlet C 11Portal Liferay Portal Portlet Portlet Por
10、tlet A Portal : Portal Portlet Portlet Portlet Portlet A Portlet B Portlet C A B C Portal Portal Portlet Portlet B A B C Portlet C 12Portal Liferay Portal Liferay Portal Professional Enterprise Liferay Portal Servlet Liferay Portal Ent J2EE Pro Servlet EJB Pro Pro Tomcat / Jetty / Resin Web Struts W
11、eb Enterprise JBoss We b Spring Web EJB Liferay Portal HSQL Liferay Portal Tomcat Liferay Portal Pro (Tomcat ) Liferay Portal Liferay Portal Liferay Portal Pro Tomcat V5 1 http:/www.iferay.om/web/guest/downloads/portal_pro Pro zip PORTAL_HOME Tomcat Liferay Liferay Web 2 JDK1.4 JDK1.5 JA V A_HOME 2.
12、1-1 3 PORTAL_HOME/bin/startup.bat Liferay Portal 4 http:/localhost Portal 135 Login test Portal Demo Liferay Portal 2.1-2 Tomcat Liferay Portal HSQL My Account Display Language Chinese(China) Portal Liferay Portal Liferay Portal Liferay 2.2.1 Liferay Portal Portlet Portal Portlet CMS 14 Portlet Life
13、ray Portal 2. 2.1 1 2.2.1-2 2.2.2 2.2.3 educhina eamoi” 2.2.3-3 15Liferay Portal 16 Liferay Portal 17 Liferay Portal 2.2.4 18 Liferay Portal 2.2.5 URL URL 2.2.6 2.2.6-1 2.2.3 2.2.6-1 2.2.6-2 2.2.3 2.2.6-2 19 Liferay Portal 2.2.6-3 2.2.6-3 2.2.6-4 2.2.6-4 2.2.7 20 Liferay Portal 2.2.8 2.2.9 2.2.9-1 2
14、.2.3 2.2.9-1 21 Liferay Portal 2.2.9-2 2.2.3 2.2.10 Portlet Portlet Portlet Portlet Portlet 22 Liferay Portal Portlet Portlet 2.2.10-2 Portlet 2.2.3 23 Liferay Portal Liferay Portal 2.3.1 24 Liferay Portal /html/layouttpl/1_column.tpl /html/layouttpl/2_columns_i.tpl /html/layouttpl/2_columns_ii.tpl
15、/html/layouttpl/1_2_1_columns.tpl Portal Portal 25 Liferay Portal 2.3.2 Portal 26 Liferay Portal 2.3.3 Portlet 27 Liferay Portal 2.3.4 Portlet Portlet Portlet Portal Web Liferay Portal 2.4.1 28 Liferay Portal 2.4.2 Liferay Portal 29Liferay Liferay Portal 2.5.1 Liferay Liferay 2.5.2 Portlet Portal 2.
16、5.3 30 Liferay Portal Liferay Portal Web Liferay Portal XML Portlet Portlet Portlet Liferay Portal Portlet Portlet Web Portlet JSR168 2.6.1 web.xml web.xml Java Web http:/ Web Liferay Portal Portlet web.xml a com.liferay.portal.servlet.PortletContextListener web Portlet Liferay Portal Portlet b Port
17、let Servlet 31 Liferay Portal yourPortlet com.liferay.portal.servlet.PortletServlet portlet-class full.name.of.yourPortlet 0 yourPortlet /yourPortlet/* servlet-name servlet init-param Portlet param-name portlet.xml liferay-portlet.xml liferay-display.xml portlet-name c http:/ /WEB-INF/tld/liferay-po
18、rtlet.tld JSP Portlet web.xml Liferay Portal liferay Struts Hibernate Spring PORTAL_HOME/liferay/WEB-INF/web.xml Portlet getPortletConfig().getInitParameter(“ ”) getPortletConfig().getParameterNames(“”) web.xml 2.6.2 portlet.xml portlet.xml Portlet resource bundle portlet-name display-name portlet-c
19、lass init-param expiration-cathe supports portlet-info security-role-ref http:/ portlet-webapp portlet-name Portlet Portlet Portlet display-name Portlet Portlet portlet-class Portlet 32 Liferay Portal javax.Portlet.GenericPortlet init-param Portlet JSP expiration-cathe Portlet -1 supports Portlet Po
20、rtlet http:/ Web Portlet Portlet xml TestPortlet TestPortlet com.educhina.portal.FirstPortlet view-jsp /view.jsp edit-jsp /edit.jsp 0 text/html text/html edit educhina Test Portlet educhina Test Portlet educhina Test Portlet guest 2.6.3 liferay-Portlet.xml Portlet http:/ 33 Liferay Portal liferay-po
21、rtlet.xml portlet.xml dtd TestPortlet TestPortlet true true administrator Administrator guest Guest power-user Power User user User 2.6.4 liferay-display.xml Portlet Liferay Portal Portlet Liferay-display.xml http:/ Liferay-display.xml portlet id liferay-portlet.xml portlet-name 34 Liferay Portal 2.
22、6.5 liferay-layout-templates.xml Portal Portal tpl liferay-layout-templates.xml layout-template xml http:/ Liferay Portal /html/layouttpl/1_column tpl /html/layouttpl/2_columns_i tpl /html/layouttpl/3_columns tpl /html/layouttpl/1_2_1_columns tpl 2.6.7 liferay-look-and-feel.xml Portal Portal Liferay
23、-look-and-feel.xml http:/ Liferay Portal 35 Liferay Portal Liferay Portal GenericPortlet Portlet Liferay Portal Liferay Portal Liferay Portal Portlet GenericPortlet Portlet GenericPortlet Servlet Portlet GenericPortlet JCP Portal JSR168 GenericPortlet Portlet JSR168 Portal GenericPortlet Portal publ
24、ic Init() public Init(PortletConfig) public getInitParameter(String) Portlet.xml public getInitParameterNames() Portlet.xml public getPortletConfig() PortletConfig public getPortletContext() Portlet public getPortletName() Portlet.xml Portlet public getResourceBundle(Locale) Portlet Resource Bundle
25、protected getTitle(RenderRequest) Portlet protected doView(RenderRequest RenderResponse) Portlet protected doEdit(RenderRequest RenderResponse) Portlet protected doHelp(RenderRequest RenderResponse) Portlet protected doDispatch(RenderRequest RenderResponse) Portlet protected processAction(RenderRequ
26、est RenderResponse) Portlet Action Request protected render(RenderRequest RenderResponse) Portal Render Request public destroy() Portlet Portlet Portal doView doEdit doHelp Portlet Servlet Portlet JSP Servlet PrintWriter pw.println() Servlet PrintWriter pw = renderResponse.getWriter(); 36pw.println(
27、“Hello world!”); Liferay Portal Servlet getInitParamter(String s) Portlet Servlet web.xml Portlet portlet.xml portlet.xml jspView /jsp/view.jsp portlet.xml SimplePortlet.java String jspName = getPortletConfig().getInitParameter(jspView); P or t let Servlet Portlet Portlet renderResponse renderReques
28、t PortletConfig JSP Portlet web.xml JSP 3.2.1 defineObjects Portlet defineObjects 3.2.2 renderURL windowState String minimized normal maximized portletMode String view edit help var String secure String true false 37 Liferay Portal RenderURL Portlet RenderURL number page 3.2.3 actionURL windowState
29、String minimized normal maximized portletMode String view edit help var String secure String true false ActionURL Portlet ActionURL action renderURL actionURL form action 3.2.4 param name String renderURL actionURL URL param body 3.2.5 namespace Portlet Va l u e Portlet Portal Va l u e PORTAL_HOME/l
30、iferay/WEB-INF/tld/liferay-portlet.tld P or t al JSR168 Portal Portal Servlet PORTAL_HOME/common/lib/ext/portlet.jar Portal 38 Liferay Portal 3.3.1 Request Portlet Request Servlet Request Servlet Portlet Request Action Request Render Request Portlet Request processAction(ActionRequest request Action
31、Response response) render(RenderRequest request RenderResponse response) Action Request Render Request render Servlet service doView doEdit doHelp doGet doPost RenderRequest ActionRequest PortletRequest RenderRequest ActionRequest renderURL actionURL renderURL actionURL Portlet renderURL actionURL a
32、ctionURL Action form Persistent session perference renderURL Portlet actionURL % PortletURL pu = renderResponse.createActionURL(); pu.setParameter(ACTION LOGIN); form name=usrform method=post action= 39% Liferay Portal Post Get Portal URL Query renderURL a href= renderURL actionURL renderURL Portal
33、Portal Portlet render actionURL Portal Portlet processAction render URL RenderRequest ActionRequest parameter actionRequest parameter processAction public void processAction(ActionRequest req ActionResponse res) String str = req.getParameter(ACTION); /response.setRenderParameter(ACTION action); publ
34、ic void doView(ActionRequest req ActionResponse res) String str = req.getParameter(ACTION); processAction getParameter ACTION Portlet processAction Portlet Container Portal Portlet render doView getParameter processAction doView ACTION action request render setRenderParameter 3.3.2 Response Request
35、Response RenderResponse ActionResponse RenderRequest ActionRequest Portlet PortletResponse serPorperty getPorperty Portal 40 Liferay Portal ActionResponse a b Portlet c parameter RenderRequest RenderResponse a ContentType b OutputStream Writer c Buffering d Portlet Portlet 3.3.3 PortletConfig Servle
36、tConfig PortletConfig Portlet PortletContext ServletConfig PortletConfig Portlet I18N Resource Bundle 3.3.4 Session Portal Session Servlet Session Portlet Portal Portlet Session Application Scope Portlet Scope Application Scope Session Portlet Portlet 41 Portlet Scope Session Portlet Portlet Liferay
37、 Portal Portlet HttpSession Portlet Web Session Scope Session JSP ActionURL PortletSession PortletSession ps = req.getPortletSession(); if(ps.getAttribute(PortletSession.AS PortletSession.APPLICATION_SCOPE)!=null) app=ps.getAttribute(PortletSession.AS PortletSession.APPLICATION_SCOPE). toString(); i
38、f(ps.getAttribute(PortletSession.PS PortletSession.PORTLET_SCOPE)!=null) Portlet=ps.getAttribute(PortletSession.PS PortletSession.PORTLET_SCOPE). toString(); Scope Session 42 Liferay Portal ServletSession PortletSession.APPLICATION_SCOPE Session HttpSession se = request.getSession(); if(se.getAttrib
39、ute(PortletSession.AS)!=null) app=se.getAttribute(PortletSession.AS); 3.3.5 Preference Preference Portlet Preference Preference - Prefe PreferencesValidator Portlet Preference rence Preference Preference Session PortletPreference p= req.getPortletPreferences(); p.setValue(educhina.username educhina)
40、; p.store(); Portlet.xml Preference 43 educhina.username educhina true Liferay Portal Preference http:/ 78 Portlet PrintWriter JSP Web Service PrintWriter JSP PortleJDK V1.4.2_06 3.4.2 JDK V1.4.2_06 JA V A_HOME JDK ANT_HOME ANT V3.0.1. liferay-portal-pro-3.6.0-tomcat.zip TestPortal D:TestPortal PORT
41、AL_HOMEcommonextportlet.jar jar APP_HOME APP_HOME webapp deploy bak APP_HOMEwebappWEB-INFclasses e=preferenceType Portlet Liferay Portal Servlet t 3.4.1 IDE Eclipse V3.0.1 ANT V1.6.2 Tomcat V5.0 Liferay Portal Liferay Portal liferay-portal-pro-3.6.0-tomcat ANT Eclipse PORTAL_HOME Eclipse Java D:Test
42、Portal APP_HOMEwebappWEB-INF web.xml APP_HOMEwebappWEB-INF tld PORTAL_HOMEliferayWEB-INFtld/liferay-portlet.tld tld 44 TestPortal Liferay Portal Java com.educhina.portal 45 3.4.3 HelloWorldPortlet HelloWorldPortlet PrintWriter Portlet com.educhina.portal Java HelloWorldPortlet javax.Portlet.GenericP
43、ortlet HelloWorldPortlet Liferay Portal HelloWorldPortlet doView doEdit doEidt RenderRequest PrintWriter String HelloWorldPortlet 3.4JSP HelloJSPPortlet Ge getPortletConfig().getInitParameter(.) Portlet xml view-jsp edit-jsp JSP Po RenderResponse package com.educhina.portal; import java.io.IOExcepti
44、on; import javax.Portlet.GenericPortlet; import javax.Portlet.PortletException; import javax.Portlet.RenderRequest; import javax.Portle.RenderResponse; public class HelloWorldPortlet extends GenericPortlet public void doView(RenderRequest req, RenderResponse res) throws IOException, PortletException
45、 res.setContentType(text/html); res.getWriter().println(HelloWorld!); public void doEdit(RenderRequest req,RenderResponse res) ption,PortletException res.setContentType(text/html); rthrows IOExce doView HelloWorld String.4 HelloJSPPortlet HelloJSPPortlet nericPortlet HelloJSPPortlet rtletRequestDisp
46、atcher include JSP 46 res.getWrite().println(HelloWorld!); Liferay Portal package com.educhina.portal; tion; import javax.Portlet.GenericPortlet; im tends GenericPortlet ublic void doView(RenderRequest req, RenderResponse res) xception tInitParameter(view-jsp); tRequestDispatcher(jspName); ublic voi
47、d doEdit(RenderRequest req,RenderResponse res) itParameter(edit-jsp); letContext().getRequestDispatcher(jspName); import java.io.IOExcepport javax.Portlet.PortletException; import javax.Portlet.PortletRequestDispatcher; import javax.Portlet.RenderRequest; import javax.Portlet.RenderResponse; public
48、class HelloJSPPortlet expthrows IOException, PortletEres.setContentType(text/html); String jspName = getPortletConfig().gePortletRequestDispatcher rd = getPortletContext().gerd.include(req,res); pthrows IOException,PortletException res.setContentType(text/html); String jspName = getPortletConfig().g
49、etInPortletRequestDispatcher rd = getPortrd.include(req,res); APP_HOME/webapp view.jsp edit.jsp view.jsp edit.jsp JSP HTML HTML Portal JSP JSP Portlet renderResponse =Portlet-font style=font-size: x-small; This is a Sample JSP Portlet used in viewing model Use this as a quick y to include JSPs d fon
50、t class wa /t 47 Liferay Portal renderRequest portletConfig Web 2. l Liferay Portal Portlet Portlet Servlet Portlet 6.1 Portlet Liferay Portal web.xm Portlet Servlet Portlet web.xml display istener-classcom.liferay.portal.servlet.PortletContextListener istener .educhina.portal.HelloWorldPortlet ad-o