Author: mrdon
Date: Thu Feb 17 13:13:31 2005
New Revision: 154192

URL: http://svn.apache.org/viewcvs?view=rev&rev=154192
Log:
Adding Struts Flow documentation and links to Struts site

Added:
    struts/core/trunk/doc/flow/
    struts/core/trunk/doc/flow/guess-example.xml   (with props)
    struts/core/trunk/doc/flow/index.xml   (with props)
    struts/core/trunk/doc/flow/project.xml
    struts/core/trunk/doc/flow/wizard-example.xml   (with props)
Modified:
    struts/core/trunk/build-site.xml
    struts/core/trunk/doc/acquiring.xml
    struts/core/trunk/doc/project.xml
    struts/core/trunk/project.xml

Modified: struts/core/trunk/build-site.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/build-site.xml?view=diff&r1=154191&r2=154192
==============================================================================
--- struts/core/trunk/build-site.xml (original)
+++ struts/core/trunk/build-site.xml Thu Feb 17 13:13:31 2005
@@ -86,7 +86,25 @@
             reloadstylesheet="true">
       <param name="project-path" expression="../userGuide/project.xml"/>
     </style>  
-
+    <!-- Create the Struts BSF site -->
+    <style   basedir="${doc.dir}/bsf"
+             destdir="${build.home}/documentation/bsf"
+           extension=".html" style="${doc.dir}/stylesheets/struts.xsl"
+            includes="*.xml"
+            excludes="project.xml"
+            reloadstylesheet="true">
+      <param name="project-path" expression="../bsf/project.xml"/>
+    </style>            
+    <!-- Create the Struts Flow site -->
+    <style   basedir="${doc.dir}/flow"
+             destdir="${build.home}/documentation/flow"
+           extension=".html" style="${doc.dir}/stylesheets/struts.xsl"
+            includes="*.xml"
+            excludes="project.xml"
+            reloadstylesheet="true">
+      <param name="project-path" expression="../flow/project.xml"/>
+    </style>            
+ 
     <!-- Copy the basic documentation files -->
     <copy      todir="${build.home}/documentation">
       <fileset   dir="${doc.dir}">

Modified: struts/core/trunk/doc/acquiring.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/doc/acquiring.xml?view=diff&r1=154191&r2=154192
==============================================================================
--- struts/core/trunk/doc/acquiring.xml (original)
+++ struts/core/trunk/doc/acquiring.xml Thu Feb 17 13:13:31 2005
@@ -131,6 +131,7 @@
       <li>http://svn.apache.org/repos/asf/struts/core/trunk</li>
       <li>http://svn.apache.org/repos/asf/struts/el/trunk</li>
       <li>http://svn.apache.org/repos/asf/struts/faces/trunk</li>
+      <li>http://svn.apache.org/repos/asf/struts/flow/trunk</li>
       <li>http://svn.apache.org/repos/asf/struts/sandbox/trunk</li>
       <li>http://svn.apache.org/repos/asf/struts/shale/trunk</li>
       <li>http://svn.apache.org/repos/asf/struts/taglib/trunk</li>

Added: struts/core/trunk/doc/flow/guess-example.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/doc/flow/guess-example.xml?view=auto&rev=154192
==============================================================================
--- struts/core/trunk/doc/flow/guess-example.xml (added)
+++ struts/core/trunk/doc/flow/guess-example.xml Thu Feb 17 13:13:31 2005
@@ -0,0 +1,110 @@
+<?xml version="1.0"?>
+<document url="guess-example.html">
+
+  <properties>
+    <title>Struts Flow - Number Guess Example</title>
+  </properties>
+
+  <body>
+      <section name="Number Guessing Game Example" href="overview">
+        <p>This example shows a number guessing game implemented with Struts 
Flow.  The goal is to show the basic concepts of continuations, so the example 
is kept simple.
+        There are basically three parts to the example: the flow code, the 
Struts config, and the JSP's that display the output.  
+        </p>
+      </section>
+      <section name="Flow Code" href="flow">
+        <p>Here is what the flow code looks like:
+        </p>
+<pre>
+function main() {
+
+  var random =  Math.round( Math.random() * 9 ) + 1;
+  var hint = "No hint for you!"
+  var guesses = 0;
+
+  while (true) {
+
+    // send guess page to user and wait for response
+    forwardAndWait("failure", 
+       { "random"  : random, 
+         "hint"    : hint,
+         "guesses" : guesses} );
+
+    // process user's guess
+    var guess = parseInt( getRequestParams().guess );
+    guesses++;
+    if (guess) {
+      if (guess > random) {
+        hint = "Nope, lower!"
+      } 
+      else if (guess &lt; random) {
+        hint = "Nope, higher!"
+      } 
+      else {
+        // correct guess
+        break;
+      }
+    }
+  }
+
+  // send success page to user
+  forwardAndWait("success", 
+     {"random"  : random, 
+      "guess"   : guess, 
+      "guesses" : guesses} );
+}
+</pre>
+        <p>Notice how the program loops until the number is guessed, even 
though pages are being sent to the 
+        browser to gather user input.</p>
+    </section>
+    <section name="Struts Configuration" href="struts">
+        <p>To configure this application with Struts, the following action 
mapping and plug-in are defined in <code>struts-config.xml</code>:</p>
+<pre>
+&lt;action-mappings>
+
+    &lt;action    path="/guess"
+               type="net.sf.struts.flow.FlowAction"
+          className="net.sf.struts.flow.FlowMapping">
+           
+      &lt;set-property property="function"   value="main"/>     
+      &lt;forward name="failure"              path="/guess.jsp"/>
+      &lt;forward name="success"              path="/success.jsp"/>
+    &lt;/action>
+&lt;/action-mappings>   
+
+
+&lt;plug-in className="net.sf.struts.flow.FlowPlugIn">
+    &lt;set-property property="scripts" value="/WEB-INF/numberguess.js" />
+&lt;/plug-in>
+</pre>
+    <p> The <code>function</code> property of the custom action mapping tells 
<code>FlowAction</code> which
+    JavaScript function to call.</p>
+  </section>
+  <section name="JSP Presentation" href="jsp">
+        <p>To gather the user's guess, <code>guess.jsp</code> generates a 
form:</p>
+<pre>
+&lt;html>
+&lt;head>
+  &lt;title>Struts Flow number guessing game&lt;/title>
+&lt;/head>
+&lt;body>
+
+  &lt;h1>Guess the Number Between 1 and 10&lt;/h1>
+  
+  &lt;h2>&lt;%= request.getAttribute("hint") %>&lt;/h2>
+  
+  &lt;h3>You've guessed &lt;%= request.getAttribute("guesses") %> 
times.&lt;/h3>
+  
+  &lt;form method="post" action="guess.do">
+    &lt;input type="hidden" name="contid" value='&lt;%= 
request.getAttribute("contid") %>' />
+    &lt;input type="text" name="guess"/>
+    &lt;input type="submit"/>
+  &lt;/form>
+  
+&lt;/body>
+&lt;/html>
+</pre>
+<p>The hidden input variable <code>contid</code> stores the continuation to 
load from when the form gets submitted.</p>
+        
+      </section>
+  </body>
+</document>

Propchange: struts/core/trunk/doc/flow/guess-example.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/core/trunk/doc/flow/index.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/doc/flow/index.xml?view=auto&rev=154192
==============================================================================
--- struts/core/trunk/doc/flow/index.xml (added)
+++ struts/core/trunk/doc/flow/index.xml Thu Feb 17 13:13:31 2005
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<document url="index.html">
+
+  <properties>
+    <title>Struts Flow</title>
+  </properties>
+
+  <body>
+
+    <section name="Struts Flow" href="overview">
+      <p>
+Struts Flow is a port of <a href="http://cocoon.apache.org";>Cocoon's</a> <a 
href="http://cocoon.apache.org/2.1/userdocs/flow/index.html";>Control Flow</a> 
to <a href="http://struts.apache.org";>Struts</a> to allow
+complex workflow, like multi-form wizards, to be easily implemented using 
continuations-capable
+JavaScript.  It provides the ability to describe the order of Web pages that 
have to be sent to the client, at any given point in time in an application.  
+Struts Flow uses a low-impact integration method that allows an existing 
Struts application to use Struts Flow along side traditional Struts 
+components like Actions and ActionForms.
+
+        </p>
+        <p>
+        While the initial target of the extracted Control Flow is Struts, the 
Flow code is reusable from other 
+        non-Struts environments.  This means Control Flow could be used to 
drive non-Struts JSP applications, portlets, or even complex web services.
+        </p>
+    </section>  
+      <section name="Features" href="features">
+            <ul>
+              <li>Easily script complex workflows</li>
+              <li>Full access to Struts features</li>
+              <li>Can exist side-by-side existing Struts actions</li>
+              <li>Ability to run in non-Struts environments (uses Jakarta's 
Commons-Chain)</li>
+              <li>Includes Wizard library to help easily create complex 
wizards</li> 
+              <li>Includes Wizard example</li> 
+              <li>Includes Cocoon's number guessing game example</li> 
+            </ul>
+      </section>
+      <section name="What's New" href="new">
+        <section name="0.2 - September 10, 2004">
+            <ul>
+              <li>Added wizard library to make wizard creation easy</li>
+              <li>Added wizard example</li>
+              <li>Updated and improved documentation</li>
+              <li>Fixed a few bugs</li>
+            </ul>
+        </section>
+        <section name="0.1 - June 3, 2004">
+            <ul>
+              <li>Hooks into Struts' logging</li>
+              <li>Added continuation expiration system</li>
+              <li>Added support for JavaScript debugger</li>
+              <li>Improved Struts integration</li>
+              <li>Added full JavaDocs</li>
+              <li>Added many more configuration options</li>
+            </ul>
+        </section>
+        <section name="Initial Import - May 12, 2004">
+            <ul>
+              <li>Example working</li>
+              <li>Struts integration functioning</li>
+              <li>Needs better Struts form integration</li>
+              <li>Needs to hook into Struts' logging</li>
+            </ul>
+        </section>
+     </section>   
+      <section name="Reqirements" href="requirements">
+          <p>
+            Struts integration requres Struts 1.1 or greater.
+          </p>
+      </section>
+      <section name="Examples" href="examples">
+        
+        <p>The following examples show how Struts Flow can be used:
+        </p>
+        <ul>
+            <li><a href="guess-example.html">Number Guess Game Example</a></li>
+            <li><a href="wizard-example.html">Wizard Example</a></li>
+        </ul>
+      </section>
+  </body>
+</document>

Propchange: struts/core/trunk/doc/flow/index.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: struts/core/trunk/doc/flow/project.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/doc/flow/project.xml?view=auto&rev=154192
==============================================================================
--- struts/core/trunk/doc/flow/project.xml (added)
+++ struts/core/trunk/doc/flow/project.xml Thu Feb 17 13:13:31 2005
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<project name="Struts Framework"
+         href="http://struts.apache.org/bsf";
+        image="images/struts.gif">
+
+    <title>Struts Flow - Apache Struts Framework</title>
+
+    <menu name="Flow">
+        <item name="Welcome" href="index.html"/>
+        <item name="What's New" href="index.html#new"/>
+        <item name="Requirements" href="index.html#requirements"/>
+        <item name="Examples" href="index.html#examples"/>
+        <item name="Download (Sourceforge)" 
href="http://sourceforge.net/project/showfiles.php?group_id=49385&amp;package_id=120079"/>
+    </menu>
+
+    <menu name="Quick Links">
+        <item 
+            name="Struts"                 
+            href="../index.html"/>
+        <item
+            name="User and Developer Guides *" 
+            href="../userGuide/index.html"/>
+        <item 
+            name="FAQs and HowTos"         
+            href="../faqs/index.html"/>
+    </menu>
+
+
+</project>
+
+
+
+
+
+

Added: struts/core/trunk/doc/flow/wizard-example.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/doc/flow/wizard-example.xml?view=auto&rev=154192
==============================================================================
--- struts/core/trunk/doc/flow/wizard-example.xml (added)
+++ struts/core/trunk/doc/flow/wizard-example.xml Thu Feb 17 13:13:31 2005
@@ -0,0 +1,148 @@
+<?xml version="1.0"?>
+<document url="wizard-example.html">
+
+  <properties>
+    <title>Struts Flow - Wizard Example</title>
+  </properties>
+
+  <body>
+      <section name="Wizard Example" href="overview">
+
+        <p>This example shows how Struts Flow can be used to easily create a 
multi-page form, commonly called a wizard.  
+        The example uses a script called <code>wizard.js</code> which uses 
Struts Flow to define a <code>Wizard</code> object. 
+        The <code>Wizard</code> object handles displaying forms, automatic 
handling of forward-backward navigation buttons, and data model population.  
+        The validation and population processes are pluggable so custom code 
can be inserted at those steps.
+        </p>
+        <p>
+        To demonstrate the wizard, this example shows a user registration 
process with three screens: names, hobbies, and a summary 
+        display.  A <code>java.util.Map</code> is used to store the 
information submitted by the forms.  
+        To keep it simple, no Struts JSP tags are used, but could be by 
wrapping model with an <code>ActionForm</code>.
+        There are three parts to the example: the flow code which uses the 
Wizard object, the Struts config, and the JSP's that display the output.  
+        </p>
+      </section>
+      <section name="Flow Code" href="flow">
+        <p>Here is what the flow code looks like:
+        </p>
+<pre>
+
+importPackage(Packages.java.util);
+context.load("/WEB-INF/wizard.js");
+
+function main() {
+  var model = new HashMap();
+
+  var wizard = new Wizard(model);
+
+  // plug in custom population method
+  wizard.populate = populate;
+
+  // plug in custom validation method
+  wizard.validate = validate;
+      
+  wizard.showForm("name-form", {
+                  "title" : "User Name Information"
+                  });
+  wizard.showForm("hobbies-form", {
+                  "title" : "User Hobbies"
+                  });
+  wizard.showForm("summary-form", {
+                  "title" : "User Summary"
+                  });  
+}
+
+function populate() {
+  m = context.chainContext.paramValues;
+  for (i = m.keySet().iterator(); i.hasNext(); ) {
+    key = i.next();
+    this.model.put(key, m.get(key)[0]);
+  }
+  // Bug in commons-chain prevents this
+  //this.model.putAll(context.chainContext.getParamValues());
+}
+
+function validate() {
+  if (this.model.get("name").length() &lt; 2) {
+    return "Name must be specified";
+  }
+}
+
+</pre>
+        <p>Notice the logic for the wizard itself is really simple.  The 
validation and population methods can either be manually done as 
+        show here, or use frameworks like commons-validator and 
commons-beanutils.  Notice also there is no handing of navigation as that 
+        is all taken care of by the Wizard object.
+        </p>
+    </section>
+    <section name="Struts Configuration" href="struts">
+        <p>To configure this application with Struts, the following action 
mapping and plug-in are defined in <code>struts-config.xml</code>:</p>
+<pre>
+  &lt;action-mappings>
+
+    &lt;action    path="/registration"
+               type="net.sf.struts.flow.FlowAction"
+          className="net.sf.struts.flow.FlowMapping">
+          
+      &lt;set-property property="function" value="main" />
+
+      &lt;forward name="name-form"              path="/name-form.jsp"/>
+      &lt;forward name="hobbies-form"              path="/hobbies-form.jsp"/>
+      &lt;forward name="summary-form"              path="/summary-form.jsp"/>
+    &lt;/action>
+ &lt;/action-mappings>   
+
+
+&lt;action-mappings>
+
+&lt;plug-in className="net.sf.struts.flow.FlowPlugIn">
+    &lt;set-property property="scripts" value="/WEB-INF/wizard-flow.js" />
+&lt;/plug-in>
+</pre>
+    <p> The <code>function</code> property of the custom action mapping tells 
<code>FlowAction</code> which
+    JavaScript function to call.  Each form in the wizard has its own 
forward.</p>
+  </section>
+  <section name="JSP Presentation" href="jsp">
+        <p>This is the first form in the wizard:</p>
+<pre>
+&lt;html>
+&lt;head>
+  &lt;title>&lt;%=request.getAttribute("title")%>&lt;/title>
+&lt;/head>
+&lt;body>
+
+  &lt;h1>&lt;%=request.getAttribute("title")%>&lt;/h1>
+  &lt;p>
+  Enter your name information:
+  &lt;/p>
+
+  &lt;center style="color:red">&lt;%=(request.getAttribute("errors") != null ? 
request.getAttribute("errors") : "")%>&lt;/center>
+  &lt;form action="registration.do" method="POST">
+
+  &lt;% java.util.Map form = (java.util.Map)request.getAttribute("form"); %>
+  &lt;table>
+   &lt;tr>
+      &lt;th>First Name&lt;/th>
+      &lt;td>&lt;input type="text" name="name" value="&lt;%=(form.get("name") 
!= null ? form.get("name") : "")%>"/>&lt;/td>
+    &lt;/tr>
+
+   &lt;tr>
+      &lt;th>Last Name&lt;/th>
+      &lt;td>&lt;input type="text" name="lastname" 
value="&lt;%=(form.get("lastname") != null ? form.get("lastname") : 
"")%>"/>&lt;/td>
+    &lt;/tr>
+
+   &lt;tr>
+      &lt;th>Middle Name&lt;/th>
+      &lt;td>&lt;input type="text" name="middlename" 
value="&lt;%=(form.get("middlename") != null ? form.get("middlename") : 
"")%>"/>&lt;/td>
+    &lt;/tr>
+  &lt;/table>
+
+  &lt;input type="hidden" name="contid" value='&lt;%= 
request.getAttribute("contid") %>' />
+  &lt;input type="submit" name="next" value="Next" />
+  &lt;/form>
+
+&lt;/body>
+&lt;/html>
+</pre>
+<p>The hidden input variable <code>contid</code> stores the continuation to 
load from when the form gets submitted.  Since no Struts JSP tags are used, 
scriptlets are necessary to retrieve and display data stored in the request.</p>
+        
+      </section>
+  </body>
+</document>

Propchange: struts/core/trunk/doc/flow/wizard-example.xml
------------------------------------------------------------------------------
    svn:executable = *

Modified: struts/core/trunk/doc/project.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/doc/project.xml?view=diff&r1=154191&r2=154192
==============================================================================
--- struts/core/trunk/doc/project.xml (original)
+++ struts/core/trunk/doc/project.xml Thu Feb 17 13:13:31 2005
@@ -40,6 +40,10 @@
             name="BSF Scripting"
             href="bsf/index.html"
             />
+        <item
+            name="Struts Flow"
+            href="flow/index.html"
+            />
     </menu>        
  
     <menu name="Documentation">

Modified: struts/core/trunk/project.xml
URL: 
http://svn.apache.org/viewcvs/struts/core/trunk/project.xml?view=diff&r1=154191&r2=154192
==============================================================================
--- struts/core/trunk/project.xml (original)
+++ struts/core/trunk/project.xml Thu Feb 17 13:13:31 2005
@@ -440,7 +440,7 @@
     <report>maven-jxr-plugin</report>
     <report>maven-junit-report-plugin</report>
     <report>maven-tasklist-plugin</report>
-    <report>maven-pmd-plugin</report>
+<!--    <report>maven-pmd-plugin</report> -->
     <report>maven-simian-plugin</report>
     <!-- <report>maven-faq-plugin</report> -->
   </reports>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to