From portal-commits at lists.jboss.org Wed Mar 21 14:56:45 2007 Content-Type: multipart/mixed; boundary="===============6440732746993046788==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6791 - docs/trunk/referenceGuide/en/modules. Date: Wed, 21 Mar 2007 14:56:43 -0400 Message-ID: --===============6440732746993046788== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2007-03-21 14:56:43 -0400 (Wed, 21 Mar 2007) New Revision: 6791 Modified: docs/trunk/referenceGuide/en/modules/contentIntegration.xml Log: improved the content integration chapter Modified: docs/trunk/referenceGuide/en/modules/contentIntegration.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 = 18:22:58 UTC (rev 6790) +++ docs/trunk/referenceGuide/en/modules/contentIntegration.xml 2007-03-21 = 18:56:43 UTC (rev 6791) @@ -85,54 +85,297 @@ - Example + Step by step example of a content driven portlet - + The Portlet skeleton + Here is the base skeleton of the content portlet. The FS= ContentDrivenPortlet shows the files which are + in the war file in which the portlet is deployed. The arbitrar= y name filesystem + will be the content type interpreted by the portlet. + + + + + Overriding the dispatch method + First the doDispatch(RenderRequest req, Render= Response resp) is overriden in order + to branch the requeset flow to a method that will take care of= displaying the editor. + + + + Utilities methods + The portlet also needs a few utilities methods which tak= e care of converting content URI to a file + back and forth. There is also an implementation of a file filt= er that keep only text files and avoid the + WEB-INF directory of the war file for security reasons. + + =3D rootPath.length() ? filePath.substring= (rootPath.length()) : null; + } +]]> + + + + The editor + The editor is probably the longest part of the portlet. = It tries to stay simple though and goes directly + to the point. + "); + writer.print("
    "); + PortletURL choseDirURL =3D resp.createRenderURL(); + if (parentPath !=3D null) { - // Get the uri value either provided by the portal or by ourself - String uri =3D req.getParameter("content.uri"); - File root =3D null; - if (uri =3D=3D null) + choseDirURL.setParameter("current_dir", parentPath); + writer.print("
  • ..
  • "); + } + for (int i =3D 0;i < children.length;i++) + { + File child =3D children[i]; + if (child.isDirectory()) { - root =3D "/"; + choseDirURL.setParameter("current_dir", getContentURI(child)); + writer.print("
  • " + child.get= Name() + "
  • "); } - else + } + writer.print("

"); + + // + writer.print("Files:
"); + writer.print("
    "); + PortletURL selectFileURL =3D resp.createActionURL(); + selectFileURL.setParameter("content.action.select", "select"); + for (int i =3D 0;i < children.length;i++) + { + File child =3D children[i]; + if (child.isFile()) { - root =3D new File(uri).getParentFile().getCanonicalPath(); + selectFileURL.setParameter("content.uri", getContentURI(child)); + writer.print("
  • " + child.g= etName() + "
  • "); } + } + writer.print("

"); = - // Get the children of the selected file - File fic =3D new File(uri); - File[] children =3D fic.listFiles(); + // + writer.close(); +} +]]>
+
+ + Viewing content at runtime + Last but not least the portlet needs to implement the doView(RenderRequest req, RenderResponse resp) + method in order to display the file that the portal window wan= ts to show. + + + + Hooking the portlet into the portal + Finally we need to make the portal aware of the fact tha= t the portlet can edit and interpret. For that + we need various descriptors. The portlet.xml descriptor will define our portlet, the + portlet-instances.xml will create a singl= e instance of our portlet and finally the + web.xml descriptor will contain a servlet= context listener that will hook the content + type in the portal content type registry. + + + ... + + File System Content Driven Portlet + FSContentDrivenPortlet + File System Content Driven Portlet + org.jboss.portal.core.portlet.test.FSContentDrivenPor= tlet + + text/html + + + File Portlet + sample,test + + + ... + +]]> + The portlet.xml descriptor + + ... + + + FSContentDrivenPortletInstance + FSContentDrivenPortlet + + + ... + + The portlet-instances.xml descriptor + + ... + + org.jboss.portal.content_type + filesystem + + + org.jboss.portal.portlet_instance + FSContentDrivenPortletInstance + + + org.jboss.portal.core.servlet.jsp.ContentTypeRegistr= ation + + ... + +]]> + The web.xml descriptor +
--===============6440732746993046788==--