Construction of Jboss-Portal Eclipse development environment

Construction of JBOSS Portal Eclipse development environment
Jboss Portal itself does not provide eclipse portlet development plug-ins, spent the whole day to find suitable JBoss Portal development environment, has tried Pluto portlet Plugin and eclipse-portalpack, discovered Pluto can not be exported WAR package directly, not too convenient, or eclipse-portalpack more practical, as will be described using the example of a HelloWorld.
1. Download the latest version of eclipse-portalpack:
  Plug introduction page: https://eclipse-portalpack.dev.java.net/
  plug 1 download the URL of: https://eclipse-portalpack.dev.java.net/files/documents /6568/51760/com.sun.jsr168.portlet.plugin_1.0.0.jar
  plug 2 download the URL of: https://eclipse-portalpack.dev.java.net/files/documents/6568/51761/com.sun.server .os.portlet.container_1.0.0.jar
2. installation eclipse-portalpack:
  download two copies of JAR packages directly to the eclipse / plugins directory to
3. run eclipse, create Portlet project:
After the eclipse start, select new-> other-> JSR 168 Portlet Porject Creator-> JSR 168 Portlet Porject Creator, as shown below:

Click "Next", enter "Porject Name" in the subsequent interface for HelloWorld, and then click Create Portlet Finish to complete the project. Item structure shown below:

4. Create Portlet Class:
After the Portlet Porject completed, you can create a specific Portlet, three basic plug has been generated JSP file: view.jsp, edit.jsp, help.jsp, so in this example can not the new JSP file, you can directly create portlet class, created as follows:
  in the number of directories eclipse of the left, select the src / java build the right point to create a new package, named com.portlet.test, and then select the package, built right point select new-> other-> JSR 168 Portlet Porject Creator-> JSR 168 Portlet, then point the Next, in the subsequent input interface "Name" is HelloWorldPortlet, "Super Class" select the javax.portlet.GenericPortlet, "Portlet Modes" option, the "View", "Edit", "Help" are checked, as shown below:

Click "finish" to complete the creation of the Portlet Class.
5. Edit Portlet Class:
  when I was debugging, discovery plug-in generated code can not run directly on JBoss Portal, it may be the identification of each application server path a little difference, we need to make changes to several paths:
  in HelloWorldPortlet. java found in
Java code

   1. PortletRequestDispatcher dispatcher = context.getRequestDispatcher("WEB-INF/jsps/view.jsp"); 
   2.     PortletRequestDispatcher dispatcher = context.getRequestDispatcher("WEB-INF/jsps/edit.jsp"); 
   3.     PortletRequestDispatcher dispatcher = context.getRequestDispatcher("WEB-INF/jsps/help.jsp"); 

PortletRequestDispatcher dispatcher = context.getRequestDispatcher("WEB-INF/jsps/view.jsp");
    PortletRequestDispatcher dispatcher = context.getRequestDispatcher("WEB-INF/jsps/edit.jsp");
    PortletRequestDispatcher dispatcher = context.getRequestDispatcher("WEB-INF/jsps/help.jsp");


Will be one of
Java code

   1. WEB-INF/jsps 

WEB-INF/jsps

Change:
the Java code duplication Code

   1. /WEB-INF/jsps 

/WEB-INF/jsps

It can be.
6. Edit Portlet.xml file:
   Unfortunately, this plugin can not be generated automatically configure the Portlet, and must be added manually.
   Found in the WEB-INF folder Portlet.xml file, add the following configuration:
the Java code duplication Code

   1. <portlet> 
   2.       <portlet-name>HelloWorldJSPPortlet</portlet-name> 
   3.       <portlet-class>com.portlet.test.HelloWorldPortlet</portlet-class> 
   4.       <supports> 
   5.          <mime-type>text/html</mime-type> 
   6.          <portlet-mode>VIEW</portlet-mode> 
   7.          <portlet-mode>EDIT</portlet-mode> 
   8.          <portlet-mode>HELP</portlet-mode> 
   9.       </supports> 
  10.       <portlet-info> 
  11.          <title>HelloWorld JSP Portlet</title> 
  12.       </portlet-info> 
  13.    </portlet> 

<portlet>
      <portlet-name>HelloWorldJSPPortlet</portlet-name>
      <portlet-class>com.portlet.test.HelloWorldPortlet</portlet-class>
      <supports>
         <mime-type>text/html</mime-type>
         <portlet-mode>VIEW</portlet-mode>
         <portlet-mode>EDIT</portlet-mode>
         <portlet-mode>HELP</portlet-mode>
      </supports>
      <portlet-info>
         <title>HelloWorld JSP Portlet</title>
      </portlet-info>
   </portlet>


7. Generate Portlet WAR package:
This step is the easiest, the eclipse left directory tree, locate the build.xml file, right click, select run As-> Ant build, to generate HelloWorld.war file in the current workspace , this war package directly copying
jboss / server / default / deploy directory, you can automatically deploy, you create an instance of this portlet with an administrator after deployment, and posted to the page, this part of the relevant, reference JBoss documentation.

Guess you like

Origin blog.csdn.net/wwzxbot/article/details/5516136
Recommended