October 24, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Dissecting Java Page Flows

  • August 24, 2005
  • By Kunal Mittal & Srinivas Kanchanavally
  • Send Email »
  • More Articles »

Page Flows in Apache Beehive

The HelloWorld example in Beehive looks a little different from the WebLogic Workshop version. Let's first look at the controller in Listing 3.

Listing 3. helloworld.jpf in Apache Beehive

import org.apache.beehive.netui.pageflow.PageFlowController;
import org.apache.beehive.netui.pageflow.annotations.Jpf;
import org.apache.beehive.netui.pageflow.Forward;
@Jpf.Controller (
   simpleActions={
      @Jpf.SimpleAction (name="cancel", path="begin.do")
      }
)
public class HelloWorldController extends PageFlowController
{
@Jpf.Action (
   forwards={
      @Jpf.Forward (name="success", path="helloworld.jsp")
      }
)
public Forward begin()
{
   return new Forward("success");}

You'll immediately notice that this version of the Java Page Flow is a lot shorter and crisper. All the Javadocs annotations at the beginning of the class code are no longer needed in the Apache Beehive version. Listing 4 shows the JSP that goes with this controller.

Listing 4. helloworld.jsp in Apache Beehive

<%@page language="java" contentType="text/html;charset=UTF-8"%>
<%@taglib uri="http://beehive.apache.org/netui/tags-html-1.0"
          prefix="netui"%>
<netui:html>
   <head>
      <title>beehive - hello world</title>
      <netui:base/>
   </head>
   <netui:body>
      <p>
         Hello World !!
         <br>
      </p>
   </netui:body>
</netui:html>

The "How to Run the Sample Code" sidebar will show you how to set up and run this example in your own environment.

HOW TO RUN THE SAMPLE CODE

Use the following steps to set up and run the HelloWorld example in your own environment.

Make a Project Folder

First, make sure you've read Appendix A. Then, on your C: drive, create a directory named beehive-projects. In the beehive-projects directory, create a directory named helloworld. Before proceeding, confirm that the following directory structure exists:

C:\
   beehive-projects
      helloworld

Copy Runtime JARs to the Project Folder

Copy the folder BEEHIVE_HOME/samples/netui-blank/resources into your project folder, C:\beehive_projects \helloworld. BEEHIVE_HOME is the top-level folder of your Beehive installation, as explained in Appendix A.

Copy the folder BEEHIVE_HOME/samples/netui-blank/WEB-INF into your project folder, C:\beehive-projects \helloworld.

Now, assemble the runtime resources for your Page Flow application. The runtime JARs include the Page Flow runtime, the NetUI tag library, and so on. You can load these resources into your project's WEB-INF/lib folder using the following Ant command at the command prompt:

ant -f %BEEHIVE_HOME%\ant\buildWebapp.xml
    -Dwebapp.dir=C:\beehive-projects
                   \helloworld deploy.beehive.webapp.runtime

This command will copy all JAR files to the WEB-INF/lib directory. Next, create the controller file, the central file for any Page Flow. Then, in the directory C:/beehive-projects/helloworld, create a file named HelloWorldController.jpf. In a text editor (or your IDE of choice), open the file HelloWorldController.jpf. In the directory C:/beehive-projects/helloworld, create a file named helloworld.jsp.

Compile and Deploy the Page Flow

You're now ready to compile the Page Flow and deploy it to Tomcat. Start the Tomcat server. Using the command shell opened in the previous step, at the command prompt, enter the following:

ant -f %BEEHIVE_HOME%\ant\buildWebapp.xml
    -Dwebapp.dir=C:\beehive-projects \helloworld
    -Dcontext.path=helloworld build.webapp deploy

To undeploy the application, use the following Ant command:

ant -f %BEEHIVE_HOME%\ant\buildWebapp.xml
    -Dwebapp.dir=C:\beehive-projects \helloworld
    -Dcontext.path=helloworld undeploy




Page 2 of 3



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel