Liferay Portlet 结构分解

简介:

 一个典型的Portlet应该有如下的结构:

 

源代码文件:

java源代码存放在<项目名>/docroot/WEB-INF/src 目录下

 

配置文件:

配置文件都在<项目名>/docroot/WEB-INF目录下,典型的有4个配置文件

portlet.xml是JSR-286相关的一些配置,它作为portlet的部署描述文件

剩余3个配置文件都是和Liferay相关的:

liferay-display.xml 文件显示portlet在Add菜单的哪个分类下

liferay-portlet.xml 文件显示Liferay对JSR-286做了哪些增强,比如配置某个portlet是否是实例化的,如下面代码第6行所示:

 
 
  1. <liferay-portlet-app> 
  2.  
  3.     <portlet> 
  4.         <portlet-name>clusternodeinfoportlet</portlet-name> 
  5.         <icon>/icon.png</icon> 
  6.         <instanceable>false</instanceable> 
  7.         <header-portlet-css>/css/main.css</header-portlet-css> 
  8.         <footer-portlet-javascript>/js/main.js</footer-portlet-javascript> 
  9.         <css-class-wrapper>clusternodeinfoportlet-portlet</css-class-wrapper> 
  10.     </portlet> 
  11.     <role-mapper> 
  12.         <role-name>administrator</role-name> 
  13.         <role-link>Administrator</role-link> 
  14.     </role-mapper> 
  15.     <role-mapper> 
  16.         <role-name>guest</role-name> 
  17.         <role-link>Guest</role-link> 
  18.     </role-mapper> 
  19.     <role-mapper> 
  20.         <role-name>power-user</role-name> 
  21.         <role-link>Power User</role-link> 
  22.     </role-mapper> 
  23.     <role-mapper> 
  24.         <role-name>user</role-name> 
  25.         <role-link>User</role-link> 
  26.     </role-mapper> 
  27. </liferay-portlet-app> 

liferay-plugin-package.properties 文件一般用于配置这个portlet所依赖jar包,然后这个portlet会被打包成war.

 

资源文件:

客户端的资源文件分别在<项目名>/docroot/目录下的js,css,html 目录下。需要注意的是,所有的html/jsp文件都不应该有全局的头比如<html><head>,所有的js,css文件都应该在指定名字空间中。

比如我们写的一段jsp页帧:

 
 
  1. <%-- 
  2. /** 
  3. * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved. 
  4. * This library is free software; you can redistribute it and/or modify it under 
  5. * the terms of the GNU Lesser General Public License as published by the Free 
  6. * Software Foundation; either version 2.1 of the License, or (at your option) 
  7. * any later version. 
  8. * This library is distributed in the hope that it will be useful, but WITHOUT 
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
  10. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
  11. * details. 
  12. */ 
  13. --%> 
  14.  
  15. <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %> 
  16.  
  17. <portlet:defineObjects /> 
  18.  
  19. <h4> 
  20. This is the <b>ClusterNodeInfoPortlet</b> portlet in View mode. 
  21. It will display the node information in the cluster.<br> 
  22. </h4> 
  23.  
  24. <br> 
  25.  
  26. <jsp:useBean id="serverName" class="java.lang.String" scope="request" /> 
  27. <jsp:useBean id="serverPort" class="java.lang.String" scope="request"/> 
  28. <jsp:useBean id="sessionId"  class="java.lang.String" scope="request"/> 
  29. <jsp:useBean id="portletSessionId" class="java.lang.String" scope="request"/> 
  30. <jsp:useBean id="portalInfo" class="java.lang.String" scope="request"/> 
  31.  
  32.  
  33. <b><font color="red">Cluster Node Information:</font></b><br> 
  34. <b>Current Server Name:</b> <%=serverName%> <br> 
  35. <b>Current Server Port:</b> <%=serverPort%> <br> 
  36. <b>Current Session Id: </b> <%=sessionId %> <br> 
  37. <b>Current Portlet Session Id:<%=portletSessionId %></b> 
  38. <b>Current Portal Info:<%=portalInfo%></b> 
  39.  
  40. <!--  
  41.     get the original http session 
  42.  --> 
  43.  
  44. <b>Current Server Session Id:<%=session.getId() %></b> 
  45. <hr> 

可以看出,这段页面是没有全局的标记<html><head>的





本文转自 charles_wang888 51CTO博客,原文链接:http://blog.51cto.com/supercharles888/881475,如需转载请自行联系原作者

目录
相关文章
|
前端开发 JavaScript 数据处理
mvc深刻理解,logic,service,model层的作用
mvc深刻理解,logic,service,model层的作用
291 0
SAP Spartacus B2B Org Unit树状结构的加载机制
SAP Spartacus B2B Org Unit树状结构的加载机制
SAP Spartacus B2B Org Unit树状结构的加载机制
|
前端开发 Java Spring
springcloud应用程序上下文层次结构
如果您从SpringApplication或SpringApplicationBuilder构建应用程序上下文,则将Bootstrap上下文添加为该上下文的父级。这是一个Spring的功能,即子上下文从其父进程继承属性源和配置文件,因此与不使用Spring Cloud Config构建相同上下文相比,“主”应用程序上下文将包含其他属性源。
1321 0
|
应用服务中间件 容器 数据格式