├── LICENCE ├── README.md ├── pom.xml └── src ├── main ├── java │ └── au │ │ └── com │ │ └── redbarn │ │ └── liferay │ │ └── spring │ │ └── mvc │ │ └── portlet │ │ └── HomeController.java ├── resources │ └── log4j.xml └── webapp │ ├── WEB-INF │ ├── liferay-display.xml │ ├── liferay-plugin-package.properties │ ├── liferay-portlet.xml │ ├── portlet.xml │ ├── spring │ │ ├── portlet-context.xml │ │ └── root-context.xml │ ├── views │ │ └── home.jsp │ └── web.xml │ ├── css │ └── main.css │ ├── icon.png │ └── js │ └── main.js └── test └── resources └── log4j.xml /LICENCE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Liferay Spring Portlet MVC 2 | ========================== 3 | 4 | A Liferay Spring Portlet MVC project template using Maven. 5 | 6 | * Liferay EE 6.2.10.11 (GA1, SP710) 7 | * Java 1.7 8 | * Portlet 2.0 9 | * Spring Framework 4.1.5 10 | * Annotation-based controller configuration 11 | 12 | Usage 13 | ----- 14 | ```bash 15 | $ git clone http://github.com/psvehla/liferay-spring-mvc-portlet.git 16 | $ cd liferay-spring-mvc-portlet 17 | $ mvn package 18 | ``` 19 | 20 | Deploy 21 | ------ 22 | If you're using Liferay Portal with Tomcat, copy the war to the deploy directory. 23 | 24 | ``` 25 | $ cp target/liferay-spring-mvc-portlet.war $LIFERAY_HOME/deploy/ 26 | ``` 27 | 28 | Configuration 29 | ------------- 30 | 31 | Default settings are Liferay EE 6.2.10.11, Java 1.7, Portlet 2.0, and Spring 4.1. All can be configured in [pom.xml](https://github.com/psvehla/liferay-spring-mvc-portlet/pom.xml) 32 | 33 | ```xml 34 | 35 | 6.2.10.11 36 | 1.7 37 | 2.0 38 | 2.5 39 | 2.2 40 | 1.2 41 | 4.1.5.RELEASE 42 | 1.8.5 43 | 1.7.10 44 | 45 | ``` 46 | 47 | Archetype 48 | --------- 49 | 50 | The main point of this project is to create a Maven archetype. 51 | 52 | Add an entry for the archetype in: ```~/.m2/archetype-catalog.xml``` 53 | 54 | ```xml 55 | 56 | au.com.redbarn 57 | liferay-spring-mvc-portlet-archetype 58 | 1.6-RELEASE 59 | https://raw.github.com/psvehla/maven-repo/master/releases 60 | liferay-spring-mvc-portlet-archetype 61 | 62 | ``` 63 | 64 | Run the maven archetype generate command. Follow the prompts to specify the groupId, artifactId, and version for your project. 65 | 66 | ```bash 67 | $ mvn archetype:generate -DarchetypeCatalog=local 68 | ``` 69 | 70 | Licence 71 | ------- 72 | 73 | Copyright 2015 Red Barn Consulting 74 | 75 | Licenced under the LGPL Licence, Version 3.0: http://www.gnu.org/licenses/lgpl.html 76 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 4.0.0 5 | au.com.redbarn 6 | liferay-spring-mvc-portlet 7 | war 8 | Liferay Spring MVC Portlet 9 | 1.6-RELEASE 10 | 11 | 12 | 3.1.1 13 | 14 | 15 | 16 | 6.2.10.11 17 | F:\java\liferay-portal-6.1.20-ee-ga2\deploy 18 | 1.7 19 | 2.0 20 | 2.5 21 | 2.2 22 | 1.2 23 | 4.1.5.RELEASE 24 | 1.8.5 25 | 1.7.10 26 | 27 | 28 | 29 | 30 | com.liferay.portal 31 | portal-service 32 | ${liferay.version} 33 | provided 34 | 35 | 36 | com.liferay.portal 37 | util-bridges 38 | ${liferay.version} 39 | provided 40 | 41 | 42 | com.liferay.portal 43 | util-taglib 44 | ${liferay.version} 45 | provided 46 | 47 | 48 | com.liferay.portal 49 | util-java 50 | ${liferay.version} 51 | provided 52 | 53 | 54 | 55 | 56 | org.springframework 57 | spring-context 58 | ${org.springframework-version} 59 | 60 | 61 | 62 | commons-logging 63 | commons-logging 64 | 65 | 66 | 67 | 68 | org.springframework 69 | spring-webmvc-portlet 70 | ${org.springframework-version} 71 | 72 | 73 | org.springframework 74 | spring-web 75 | ${org.springframework-version} 76 | 77 | 78 | 79 | 80 | org.aspectj 81 | aspectjrt 82 | ${org.aspectj-version} 83 | 84 | 85 | 86 | 87 | org.slf4j 88 | slf4j-api 89 | ${org.slf4j-version} 90 | 91 | 92 | org.slf4j 93 | jcl-over-slf4j 94 | ${org.slf4j-version} 95 | runtime 96 | 97 | 98 | org.slf4j 99 | slf4j-log4j12 100 | ${org.slf4j-version} 101 | runtime 102 | 103 | 104 | log4j 105 | log4j 106 | 1.2.17 107 | 108 | 109 | javax.mail 110 | mail 111 | 112 | 113 | javax.jms 114 | jms 115 | 116 | 117 | com.sun.jdmk 118 | jmxtools 119 | 120 | 121 | com.sun.jmx 122 | jmxri 123 | 124 | 125 | runtime 126 | 127 | 128 | 129 | 130 | javax.inject 131 | javax.inject 132 | 1 133 | 134 | 135 | 136 | 137 | javax.portlet 138 | portlet-api 139 | ${portlet-api.version} 140 | provided 141 | 142 | 143 | 144 | 145 | javax.servlet 146 | servlet-api 147 | ${servlet-api.version} 148 | provided 149 | 150 | 151 | javax.servlet.jsp 152 | jsp-api 153 | ${jsp-api.version} 154 | provided 155 | 156 | 157 | javax.servlet 158 | jstl 159 | ${jstl.version} 160 | 161 | 162 | 163 | 164 | junit 165 | junit 166 | 4.12 167 | test 168 | 169 | 170 | 171 | 172 | 173 | 174 | com.liferay.maven.plugins 175 | liferay-maven-plugin 176 | ${liferay.version} 177 | 178 | ${liferay.auto.deploy.dir} 179 | ${liferay.app.server.portal.dir} 180 | ${liferay.version} 181 | portlet 182 | 183 | 184 | 185 | maven-compiler-plugin 186 | 3.1 187 | 188 | UTF-8 189 | ${java-version} 190 | ${java-version} 191 | 192 | 193 | 194 | org.apache.maven.plugins 195 | maven-resources-plugin 196 | 2.6 197 | 198 | UTF-8 199 | 200 | 201 | 202 | org.apache.maven.plugins 203 | maven-eclipse-plugin 204 | 2.9 205 | 206 | true 207 | false 208 | 2.0 209 | 210 | **/.svn/** 211 | 212 | 213 | 214 | 215 | org.apache.maven.plugins 216 | maven-dependency-plugin 217 | 218 | 219 | install 220 | install 221 | 222 | sources 223 | 224 | 225 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /src/main/java/au/com/redbarn/liferay/spring/mvc/portlet/HomeController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of liferay-spring-mvc-portlet. 3 | * 4 | * liferay-spring-mvc-portlet is free software: you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License as published by the 6 | * Free Software Foundation, either version 3 of the License, or (at your option) 7 | * any later version. 8 | * 9 | * liferay-spring-mvc-portlet is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 11 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | * more details. 13 | * 14 | * You should have received a copy of the GNU General Public License along with 15 | * liferay-spring-mvc-portlet. If not, see . 16 | */ 17 | package au.com.redbarn.liferay.spring.mvc.portlet; 18 | 19 | import java.text.DateFormat; 20 | import java.util.Date; 21 | import java.util.Locale; 22 | 23 | import org.springframework.stereotype.Controller; 24 | import org.springframework.ui.Model; 25 | import org.springframework.web.bind.annotation.RequestMapping; 26 | import org.springframework.web.portlet.bind.annotation.RenderMapping; 27 | 28 | import com.liferay.portal.kernel.log.Log; 29 | import com.liferay.portal.kernel.log.LogFactoryUtil; 30 | 31 | /** 32 | * Handles requests for the view mode. 33 | */ 34 | @Controller 35 | @RequestMapping("VIEW") 36 | public class HomeController { 37 | 38 | private static final Log log = LogFactoryUtil.getLog(HomeController.class); 39 | 40 | /** 41 | * Simply selects the home view to render by returning its name. 42 | */ 43 | @RenderMapping 44 | public String home(Locale locale, Model model) { 45 | 46 | log.info("Welcome home! the client locale is "+ locale.toString()); 47 | 48 | Date date = new Date(); 49 | DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); 50 | 51 | String formattedDate = dateFormat.format(date); 52 | 53 | model.addAttribute("serverTime", formattedDate); 54 | 55 | return "home"; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/liferay-display.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/liferay-plugin-package.properties: -------------------------------------------------------------------------------- 1 | name=liferay-spring-mvc-portlet 2 | module-group-id=liferay 3 | module-incremental-version=1 4 | tags= 5 | short-description= 6 | change-log= 7 | page-url=http://www.liferay.com 8 | author=Liferay, Inc. 9 | licenses=LGPL -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/liferay-portlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | liferay-spring-mvc-portlet 7 | /icon.png 8 | false 9 | /css/main.css 10 | /js/main.js 11 | 12 | 13 | administrator 14 | Administrator 15 | 16 | 17 | guest 18 | Guest 19 | 20 | 21 | power-user 22 | Power User 23 | 24 | 25 | user 26 | User 27 | 28 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/portlet.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | liferay-spring-mvc-portlet 11 | Liferay Spring MVC Portlet 12 | org.springframework.web.portlet.DispatcherPortlet 13 | 14 | contextConfigLocation 15 | /WEB-INF/spring/portlet-context.xml 16 | 17 | 0 18 | 19 | text/html 20 | view 21 | 22 | 23 | Liferay Spring MVC Portlet 24 | Liferay Spring MVC Portlet 25 | liferay spring mvc portlet 26 | 27 | 28 | administrator 29 | 30 | 31 | guest 32 | 33 | 34 | power-user 35 | 36 | 37 | user 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/spring/portlet-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/spring/root-context.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/views/home.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | 3 |

Liferay Spring Portlet MVC

4 | 5 |

The time on the server is ${serverTime}.

6 | 7 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | contextConfigLocation 9 | /WEB-INF/spring/root-context.xml 10 | 11 | 12 | org.springframework.web.context.ContextLoaderListener 13 | 14 | 15 | ViewRendererServlet 16 | org.springframework.web.servlet.ViewRendererServlet 17 | 1 18 | 19 | 20 | ViewRendererServlet 21 | /WEB-INF/servlet/view 22 | 23 | -------------------------------------------------------------------------------- /src/main/webapp/css/main.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psvehla/liferay-spring-mvc-portlet/548af97c6f8af79499321318c814c0529d987825/src/main/webapp/css/main.css -------------------------------------------------------------------------------- /src/main/webapp/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psvehla/liferay-spring-mvc-portlet/548af97c6f8af79499321318c814c0529d987825/src/main/webapp/icon.png -------------------------------------------------------------------------------- /src/main/webapp/js/main.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/psvehla/liferay-spring-mvc-portlet/548af97c6f8af79499321318c814c0529d987825/src/main/webapp/js/main.js -------------------------------------------------------------------------------- /src/test/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | --------------------------------------------------------------------------------