You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by st...@apache.org on 2005/12/02 22:47:38 UTC

svn commit: r351842 - in /beehive/trunk/docs/forrest/release/src/documentation/content/xdocs: netui/tutorial_pageflow.xml setup.xml site.xml

Author: steveh
Date: Fri Dec  2 13:47:34 2005
New Revision: 351842

URL: http://svn.apache.org/viewcvs?rev=351842&view=rev
Log:
Adding control step to the pageflow tutorial.

The tutorial is getting long at this point.  The validation steps (step 7 +) should probably be moved into a standalone tutorial.

Modified:
    beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/netui/tutorial_pageflow.xml
    beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/setup.xml
    beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/site.xml

Modified: beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/netui/tutorial_pageflow.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/netui/tutorial_pageflow.xml?rev=351842&r1=351841&r2=351842&view=diff
==============================================================================
--- beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/netui/tutorial_pageflow.xml (original)
+++ beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/netui/tutorial_pageflow.xml Fri Dec  2 13:47:34 2005
@@ -43,6 +43,7 @@
                     <a href="site:docs/pageflow/tags/pageflow_tag_overview">NetUI JSP tag library</a>.
                 </li>
                 <li>How page flows help to separate data processing and data presentation.</li>
+                <li>How to make a web application a client of a <a href="site:control_overview">Java control</a>.</li>
                 <li>
                     How to use 
                     <a href="site:docs/pageflow/netuiBasic/validation">declarative validation</a> with data submission.
@@ -72,8 +73,8 @@
                 </p>
                 <ol>
                 <li>Create a directory <code>/beehive_projects</code> (on Windows, this would be <code>C:\beehive_projects</code>).</li>
-                <li>Run the Ant target to create a new NetUI project:
-                    <code>ant -f &lt;beehive-root>/beehive-imports.xml</code> and provide a fully-qualified web project root directory
+                <li>Run this Ant target to create a new NetUI project:
+                    <code>ant -f &lt;beehive-root>/beehive-imports.xml new.netui.webapp</code> and provide a fully-qualified web project root directory
                     named <code>netui-tutorial</code>.  Note, <code>&lt;beehive-root></code> is the directory that contains a 
                     Beehive distribution; a typical value might be <code>/apache/apache-beehive-1.0</code>.</li>
                 <li>Before continuing, confirm that the following directory structure exists:</li>
@@ -81,6 +82,7 @@
                 <source>
     beehive_projects/
         netui-tutorial/
+            src/
             web/
                 Controller.java
                 index.jsp
@@ -234,9 +236,7 @@
                 <p><strong><code>web/myFlow/index.jsp</code></strong></p>
 <source><![CDATA[
 <%@ page language="java" contentType="text/html;charset=UTF-8"%>
-<%@ taglib uri="http://beehive.apache.org/netui/tags-databinding-1.0" prefix="netui-data"%>
 <%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
-<%@ taglib uri="http://beehive.apache.org/netui/tags-template-1.0" prefix="netui-template"%>
 <netui:html>
   <head>
     <title>Web Application Page</title>
@@ -605,8 +605,131 @@
                 </note>
             </section>
         </section>
+        <section id="addControl">
+            <title>Step 6: Add a Control</title>
+            <p>In this step you will add a simple 'Hello World' control to your web application.</p>
+            <p>You will edit the web application to become a client of the control.  The web app will pass the user submitted 
+            name to the control, and the control will return a simple 'Hello World' message back to the web app.
+            For more details on how this control works see the <a href="site:tutorial_control">control tutorial</a>.</p>
+                <section>
+                <title>Create the HelloWorld Control</title>
+                    <p>Inside the <code>netui-tutorial/src</code> directory, create a new directory named <code>controls</code>.</p>
+                    <p>Inside the directory <code>netui-tutorial/src/controls</code>, create a new file named <code>HelloWorldImpl.java</code></p>
+                    <p>Edit <code>HelloWorldImpl.java</code> so it appears as follows:</p>
+                    <source>package controls;
+
+import org.apache.beehive.controls.api.bean.ControlImplementation;
+
+@ControlImplementation(isTransient=true)
+public class HelloWorldImpl implements HelloWorld {
+
+    public String hello() {
+        return "hello!";
+    }
+
+    public String helloParam(String name) {
+        return "Hello, " + name + "!";
+    }
+}</source>
+                    <p>Inside the directory <code>netui-tutorial/src/controls</code>, create a new file named <code>HelloWorld.java</code></p>
+                    <p>Edit <code>HelloWorld.java</code> so it appears as follows:</p>
+                    <source>package controls;
+
+import org.apache.beehive.controls.api.bean.ControlInterface;
+
+@ControlInterface
+public interface HelloWorld {
+
+    String hello();
+
+    String helloParam(String name);
+}</source>
+                </section>
+                <section>
+                    <title>Edit the Page Flow Controller</title>    
+                    <p>Edit the page flow Controller file so it appears as follows.  Code to add appears in bold:</p>
+                    <source>package myFlow;
+
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import forms.ProfileForm;
+
+<strong>import org.apache.beehive.controls.api.bean.Control;
+import controls.HelloWorld;</strong>
+
+@Jpf.Controller(
+    simpleActions={
+        @Jpf.SimpleAction(name="begin", path="index.jsp"),
+        @Jpf.SimpleAction(name="toPage2", path="page2.jsp")
+    }
+)
+public class Controller 
+    extends PageFlowController
+{
+    <strong>@Control
+    private HelloWorld _helloWorld;</strong>
+	
+    @Jpf.Action(
+        forwards = { 
+            @Jpf.Forward(name="success", path="displayData.jsp")
+        }
+    )
+    public Forward processData(ProfileForm form) {
+        System.out.println("Name: " + form.getName());
+        System.out.println("Age: " + form.getAge());
+        
+        Forward fwd = new Forward("success");
+        fwd.addActionOutput("name", form.getName());
+        fwd.addActionOutput("age", form.getAge());
+        <strong>fwd.addActionOutput("message", _helloWorld.helloParam( form.getName()));</strong>
+        return fwd;
+    }	  
+}</source>
+                </section>
+                <section>
+                    <title>Add a New pageInput</title>
+                    <p>Add new pageinput to displayData.jsp.  Code to add appears in bold:</p>
+                    <source>&lt;%@ page language="java" contentType="text/html;charset=UTF-8"%>
+&lt;%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"%>
+&lt;netui:html>
+  &lt;head>
+    &lt;title>displayData.jsp&lt;/title>
+    &lt;netui:base/>
+  &lt;/head>
+  &lt;netui:body>
+    &lt;p>
+      You submitted the following information:
+    &lt;/p>
+    &lt;p>
+      Name: ${pageInput.name}
+      &lt;br/>
+      Age: ${pageInput.age}
+      <strong>&lt;br/>
+      Message: ${pageInput.message}</strong>
+    &lt;/p>
+  &lt;/netui:body>
+&lt;/netui:html>
+                    </source>
+                </section>
+            <section>
+                <title>Recompile and Redeploy the Web Application</title>
+                <p>Compile and (re)deploy the web application using the same steps as described <a href="#create_build_deploy">here</a>.</p>
+            </section>
+            <section>
+                <title>Test the NetUI Web Application</title>
+                <p>Visit the following link: 
+                </p>
+                <p><a class="fork" href="http://localhost:8080/netui-tutorial/myFlow/Controller.jpf">http://localhost:8080/netui-tutorial/myFlow/Controller.jpf</a></p>
+                <p>You will be directed to the <code>index.jsp</code> page.</p>
+                <p>Click the link.</p>
+                <p>You will be directed to page2.jsp.</p>
+                <p>Enter values in the Name and Age fields. Click the Submit button.</p>
+                <p>You will be forwarded to the <code>displayData.jsp</code> page.  Notice the values you entered are displayed along with a 'Hello World' message based on the name you submitted.</p>
+            </section>
+        </section>
         <section id="validation">
-            <title>Step 6: Input Validation</title>
+            <title>Step 7: Input Validation</title>
             <section id="validation_add">
                 <title>Add Declarative Validation to the Form Bean</title>
                 <p>In this step you will use declarative validation to define the set of rules for each
@@ -706,6 +829,9 @@
 import org.apache.beehive.netui.pageflow.Forward;
 import forms.ProfileForm;
 
+import org.apache.beehive.controls.api.bean.Control;
+import controls.HelloWorld;
+
 @Jpf.Controller(
     simpleActions={
         @Jpf.SimpleAction(name="begin", path="index.jsp"),
@@ -715,6 +841,9 @@
 public class Controller
     extends PageFlowController
 {
+    @Control
+    private HelloWorld _helloWorld;
+
     @Jpf.Action(
         forwards = {
             @Jpf.Forward(name="success", path="displayData.jsp")
@@ -728,6 +857,7 @@
         Forward fwd = new Forward("success");
         fwd.addActionOutput("name", form.getName());
         fwd.addActionOutput("age", form.getAge());
+        fwd.addActionOutput("message", _helloWorld.helloParam( form.getName()));
         return fwd;
     }
 }</source>
@@ -788,7 +918,7 @@
             </section>
         </section>
         <section id="nested">
-            <title>Step 7: Collect Data from a Nested Page Flow</title>
+            <title>Step 8: Collect Data from a Nested Page Flow</title>
             <p>
                 <a href="site:docs/pageflow/netuiBasic/nestedPageFlow">Nested page flows</a> allow you to insert
                 <em>entire flows</em> in the middle of the current flow.  One use for this is to collect data in another
@@ -875,7 +1005,7 @@
                     annotation of the <code>processData</code> method. The
                     ProfileForm is page flow-scoped for this example, using the same Form Bean
                     instance in multiple Action methods.</p>
-                <p><strong><code>Controller.java</code></strong></p>
+                <p><strong><code>web/myFlow/Controller.java</code></strong></p>
                 <source>
 package myFlow;
 
@@ -884,6 +1014,9 @@
 import org.apache.beehive.netui.pageflow.Forward;
 import forms.ProfileForm;
 
+import org.apache.beehive.controls.api.bean.Control;
+import controls.HelloWorld;
+
 @Jpf.Controller(
     simpleActions={
         @Jpf.SimpleAction(name="begin", path="index.jsp"),
@@ -894,6 +1027,9 @@
     extends PageFlowController 
 {
 
+    @Control
+    private HelloWorld _helloWorld;
+
     <strong>private ProfileForm profileForm;
 
     /**
@@ -951,7 +1087,10 @@
     public Forward processData(ProfileForm form) {
         System.out.println("Name: " + form.getName());
         System.out.println("Age: " + form.getAge());
-        getRequest().setAttribute("data", form);
+
+        fwd.addActionOutput("name", form.getName());
+        fwd.addActionOutput("age", form.getAge());
+        fwd.addActionOutput("message", _helloWorld.helloParam( form.getName()));
         return new Forward("success");
     }
 }
@@ -1132,6 +1271,8 @@
       Name: ${pageInput.name}
       &lt;br/>
       Age: ${pageInput.age}
+      &lt;br/>
+      Message: ${pageInput.message}      
       <strong>&lt;br/>
       Sport: ${pageInput.sport}</strong>
     &lt;/p>
@@ -1160,7 +1301,7 @@
             </section>
         </section>
         <section id="sharedflow">
-            <title>Step 8: Adding Actions to a Shared Flow</title>
+            <title>Step 9: Adding Actions to a Shared Flow</title>
             <section id="sharedflow_page">
                 <title>To Create a Common Destination JSP</title>
                 <p>In the directory <code>web/myFlow</code>, create a file named <code>help.jsp</code>.</p>

Modified: beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/setup.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/setup.xml?rev=351842&r1=351841&r2=351842&view=diff
==============================================================================
--- beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/setup.xml (original)
+++ beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/setup.xml Fri Dec  2 13:47:34 2005
@@ -12,7 +12,7 @@
         </p>
             <p>(1) The following software is required for developing Beehive applications:</p>
             <ul>
-                <li>Beehive Binary Distribution -- download from <a class="fork" href="site:beehive-release/current">http://cvs.apache.org/dist/incubator/beehive/v1.0m1</a></li>
+                <li>Beehive Binary Distribution -- download from <a class="fork" href="site:beehive-release/current">http://beehive.apache.org/releases/release-1.0.cgi</a></li>
                 <li>Ant 1.6.2 -- download from <a class="fork" href="site:ant16/download">http://ant.apache.org/bindownload.cgi</a></li>
                 <li>J2SE 5.0 JDK -- download from <a class="fork" href="site:java5download">http://java.sun.com/j2se/1.5.0/download.jsp</a></li>
             </ul>

Modified: beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/site.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/site.xml?rev=351842&r1=351841&r2=351842&view=diff
==============================================================================
--- beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/site.xml (original)
+++ beehive/trunk/docs/forrest/release/src/documentation/content/xdocs/site.xml Fri Dec  2 13:47:34 2005
@@ -182,8 +182,8 @@
     </docs>
     <external-refs>
         <beehive href="http://beehive.apache.org/"/>
-        <beehive-release href="http://cvs.apache.org/">
-            <current href="dist/incubator/beehive/v1.0m1"/>
+        <beehive-release href="http://beehive.apache.org/">
+            <current href="releases/release-1.0.cgi"/>
         </beehive-release>
         <jsr href="http://jcp.org/en/jsr/detail">
             <n181 href="?id=181"/>