Download presentation
Presentation is loading. Please wait.
1
Copyright © 2000-2006 Liferay, Inc.
Basic Portlet Copyright © Liferay, Inc. All Rights Reserved. No material may be reproduced electronically or in print without written permission from Liferay, LLC.
2
Introduction Difficulty Level: Easy
The source code for this presentation is located here: source-code-part1 Make sure to read the code! It’s important to become familiar with the basic structure before the exercises get more complicated.
3
Objectives The goal of this tutorial is to create a JSP portlet
Define the portlet portlet-ext.xml liferay-portlet-ext.xml Create the JSP view.jsp
4
Directory Structure Configuration files are located here: ext\ext-web\docroot\WEB-INF JSPs are located here: ext\ext-web\docroot\html
5
Define the Portlet The first step will be to define the portlet in portlet-ext.xml The second step will be to define the portlet in liferay-portlet-ext.xml
6
portlet-ext.xml <portlet>
<portlet-name>EXT_2</portlet-name> <display-name>JSP Portlet Introduction</display-name> <portlet-class>com.liferay.portlet.JSPPortlet</portlet- class> <init-param> <name>view-jsp</name> <value>/portlet/ext/jsp_portlet/view.jsp</value> </init-param> <expiration-cache>0</expiration-cache>
7
<supports> <mime-type>text/html</mime-type> </supports> <resource- bundle>com.liferay.portlet.StrutsResourceBundle</resou rce-bundle> <security-role-ref> <role-name>power-user</role-name> </security-role-ref> <role-name>user</role-name> </portlet>
8
Checkpoint What is <portlet-name> used for?
What is <portlet-class> used for? What is view-jsp? What is /portlet/ext/jsp_portlet/view.jsp? What is <role-name> used for?
9
liferay-portlet-ext.xml The second step is to define the portlet in liferay-portlet-ext.xml <portlet> <portlet-name>EXT_2</portlet-name> </portlet>
10
view.jsp Create the following directory structure: ext\ext-web\docroot\html\portlet\ext\jsp_portlet Create view.jsp ext\ext-web\docroot\html\portlet\ext\jsp_portlet \view.jsp Enter the following in view.jsp JSP Portlet!
11
Checkpoint Why did we place view.jsp here? ext\ext-web\docroot\html\portlet\ext\jsp_portlet \view.jsp Hint: portlet-ext.xml Where are configuration files like portlet- ext.xml and liferay-portlet-ext.xml located?
12
Deploy the Files to Tomcat
Click Start Run… Type cmd and press Enter Navigate to C:\Training\liferay\ext Type ant deploy
13
Checkpoint Verify that your files were deployed to Tomcat correctly. This is a required step! Go to \tomcat\webapps\ROOT\WEB-INF Check portlet-ext.xml and liferay-portlet-ext.xml and make sure they are correct Go to tomcat\webapps\ROOT\html\portlet \ext\jsp_portlet Make sure that view.jsp exists and that it is correct See the Troubleshooting section if your files were not deployed correctly.
14
Final Steps Restart Tomcat: Click on the Tomcat Window Press Ctrl-C Double click startup.bat Open up a new browser and type Login: Password: test Click Add Content Undefined Click javax.portlet.title.EXT_2
15
Troubleshooting Question: My files are not being deployed to Tomcat correctly! Answer: You have an error in app.server.{user.name}.properties Make sure that app.server.{user.name}.properties is located in C:/Training/liferay/ext Verify that your {user.name} is correct Make sure that app.server.{user.name}.properties contains the following: app.server.type=tomcat app.server.tomcat.dir=C:/Training/liferay/tomcat
16
Troubleshooting Question: My portlet is not showing up when I click Add Content Undefined Answer: Your portlet is not defined correctly in portlet-ext.xml or liferay-portlet-ext.xml Check portlet-ext.xml and liferay-portlet-ext.xml in C:/Training/liferay/tomcat/webapps/ROOT/WEB-INF Make sure that the EXT_2 portlet is defined correctly.
17
Congratulations! You’ve created your first JSP Portlet!
Defined the portlet in portlet-ext.xml Defined the portlet in liferay-portlet-ext.xml Created the JSP in ext\ext-web\docroot\html\portlet\ext\jsp_portlet \view.jsp
18
Revision History Edward Shin 09/14/06 Updated for Liferay 4.1.2
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.