Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

JSP Portlet

7,233 views

Published on

Published in: Technology
  • Be the first to comment

JSP Portlet

  1. 1. Basic Portlet
  2. 2. Objectives <ul><li>The goal of this tutorial is to create a JSP portlet </li></ul><ul><li>Define the portlet portlet-ext.xml liferay-portlet-ext.xml </li></ul><ul><li>Create the JSP view.jsp </li></ul>
  3. 3. Directory Structure <ul><li>Configuration files are located here: extext-webdocrootWEB-INF </li></ul><ul><li>JSPs are located here: extext-webdocroothtml </li></ul>
  4. 4. Define the Portlet <ul><li>The first step will be to define the portlet in portlet-ext.xml </li></ul><ul><li>The second step will be to define the portlet in liferay-portlet-ext.xml </li></ul>
  5. 5. portlet-ext.xml <ul><li><portlet> </li></ul><ul><li><portlet-name>EXT_2</portlet-name> </li></ul><ul><li><display-name>JSP Portlet Introduction</display-name> </li></ul><ul><li><portlet-class>com.liferay.portlet.JSPPortlet</portlet-class> </li></ul><ul><li><init-param> </li></ul><ul><li><name>view-jsp</name> </li></ul><ul><li><value>/portlet/ext/jsp_portlet/view.jsp</value> </li></ul><ul><li></init-param> </li></ul><ul><li><expiration-cache>0</expiration-cache> </li></ul>
  6. 6. portlet-ext.xml <ul><li><supports> </li></ul><ul><li><mime-type>text/html</mime-type> </li></ul><ul><li></supports> </li></ul><ul><li><resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle> </li></ul><ul><li><security-role-ref> </li></ul><ul><li><role-name>power-user</role-name> </li></ul><ul><li></security-role-ref> </li></ul><ul><li><security-role-ref> </li></ul><ul><li><role-name>user</role-name> </li></ul><ul><li></security-role-ref> </li></ul><ul><li></portlet> </li></ul>
  7. 7. liferay-portlet-ext.xml <ul><li>The second step is to define the portlet in liferay-portlet-ext.xml </li></ul><ul><li><portlet> </li></ul><ul><li><portlet-name>EXT_2</portlet-name> </li></ul><ul><li></portlet> </li></ul>
  8. 8. view.jsp <ul><li>Create the following directory structure: extext-webdocroothtmlportletextjsp_portlet </li></ul><ul><li>Create view.jsp extext-webdocroothtmlportletextjsp_portlet view.jsp </li></ul><ul><li>Enter the following in view.jsp JSP Portlet! </li></ul>
  9. 9. Change Title and Add to Category <ul><li>Set the Title Language-ext.properties </li></ul><ul><li>Add the portlet to a Category liferay-display.xml </li></ul>
  10. 10. Directory Structure <ul><li>Configuration files are located here: extext-webdocrootWEB-INF </li></ul><ul><li>Property files are located here: extext-ejbclasses </li></ul>
  11. 11. Language-ext.properties <ul><li>The first step is to change the Title from javax.portlet.title.EXT_2 to JSP Portlet! </li></ul><ul><li>Go to extext-ejbclassescontent Language-ext.properties </li></ul><ul><li>Enter the following in Language-ext.properties: javax.portlet.title.EXT_2=JSP Portlet! </li></ul>
  12. 12. liferay-display.xml <ul><li>Next, let’s add our portlet to the Test Category </li></ul><ul><li>Go to extext-webdocrootWEB-INF liferay-display.xml </li></ul><ul><li>Enter the following in liferay-display.xml: <category name=&quot;category.test&quot;> <portlet id=“47” /> … <portlet id=&quot;EXT_1&quot; /> <portlet id=&quot;EXT_2&quot; /> </category> </li></ul>
  13. 13. Deploy to Tomcat <ul><li>Click Start  Run… </li></ul><ul><li>Type cmd and press Enter </li></ul><ul><li>Navigate to C:Trainingliferayext </li></ul><ul><li>Type ant deploy </li></ul>
  14. 14. Final Steps <ul><li>Restart Tomcat: Click on the Tomcat Window Press Ctrl-C Double click startup.bat </li></ul><ul><li>Open up a new browser and type http://localhost:8080 Login: test@liferay.com Password: test </li></ul><ul><li>Click Add Content  Test </li></ul><ul><li>Click EXT_2 </li></ul>

×