You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ri...@apache.org on 2005/05/25 05:34:28 UTC

svn commit: r178353 - in /incubator/beehive/trunk/samples/netui-samples: ./ WEB-INF/src/org/apache/beehive/samples/netui/resources/nesting/ nesting/ nesting/chooseairport/

Author: rich
Date: Tue May 24 20:34:27 2005
New Revision: 178353

URL: http://svn.apache.org/viewcvs?rev=178353&view=rev
Log:
Added a feature sample for nested page flows.

tests: build.dist (WinXP)
BB (and run.tests against the distributions): self (linux)


Added:
    incubator/beehive/trunk/samples/netui-samples/WEB-INF/src/org/apache/beehive/samples/netui/resources/nesting/
    incubator/beehive/trunk/samples/netui-samples/WEB-INF/src/org/apache/beehive/samples/netui/resources/nesting/chooseairport.properties   (with props)
    incubator/beehive/trunk/samples/netui-samples/nesting/
    incubator/beehive/trunk/samples/netui-samples/nesting/Controller.java   (with props)
    incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/
    incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/ChooseAirport.java   (with props)
    incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/confirm.jsp   (with props)
    incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/findairport.jsp   (with props)
    incubator/beehive/trunk/samples/netui-samples/nesting/index.jsp   (with props)
    incubator/beehive/trunk/samples/netui-samples/nesting/results.jsp   (with props)
Modified:
    incubator/beehive/trunk/samples/netui-samples/index.jsp

Added: incubator/beehive/trunk/samples/netui-samples/WEB-INF/src/org/apache/beehive/samples/netui/resources/nesting/chooseairport.properties
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/WEB-INF/src/org/apache/beehive/samples/netui/resources/nesting/chooseairport.properties?rev=178353&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/WEB-INF/src/org/apache/beehive/samples/netui/resources/nesting/chooseairport.properties (added)
+++ incubator/beehive/trunk/samples/netui-samples/WEB-INF/src/org/apache/beehive/samples/netui/resources/nesting/chooseairport.properties Tue May 24 20:34:27 2005
@@ -0,0 +1,4 @@
+displayname.searchtext=The search text
+
+error.prefix=<span style="color:red;">
+error.suffix=</span>

Propchange: incubator/beehive/trunk/samples/netui-samples/WEB-INF/src/org/apache/beehive/samples/netui/resources/nesting/chooseairport.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/beehive/trunk/samples/netui-samples/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/index.jsp?rev=178353&r1=178352&r2=178353&view=diff
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/index.jsp (original)
+++ incubator/beehive/trunk/samples/netui-samples/index.jsp Tue May 24 20:34:27 2005
@@ -36,13 +36,18 @@
               inheritance.</dd>
       </dl>
       <dl>
+          <dt><netui:anchor href="nesting/Controller.jpf" value="Nested Page Flow"/></dt>
+          <dd>Demonstrates a simple nested page flow that returns data back to the original page
+              flow.</dd>
+      </dl>
+      <dl>
           <dt><netui:anchor href="templateactions/MainFlow.jpf" value="Template Actions"/></dt>
           <dd>Demonstrates the use of a shared flow to provide actions for a template page (like a
               template that contains a menu bar).</dd>
       </dl>
       <dl>
           <dt><netui:anchor href="validation/Controller.jpf" value="Validation"/></dt>
-          <dd>This sample demonstrates the declarative validation model.</dd>
+          <dd>This sample demonstrates Page Flow declarative field validation.</dd>
       </dl>
       <br/>
       <b>NetUI JSP Tags</b>

Added: incubator/beehive/trunk/samples/netui-samples/nesting/Controller.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/nesting/Controller.java?rev=178353&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/nesting/Controller.java (added)
+++ incubator/beehive/trunk/samples/netui-samples/nesting/Controller.java Tue May 24 20:34:27 2005
@@ -0,0 +1,40 @@
+package nesting;
+
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+
+@Jpf.Controller(
+    simpleActions={
+        @Jpf.SimpleAction(name="begin", path="index.jsp"),
+
+        // This action runs the Choose Airport wizard.  Since the ChooseAirport page flow is marked
+        // with nested=true, it will be able to return control to this page flow when it is done.
+        @Jpf.SimpleAction(name="chooseAirport", path="/nesting/chooseairport/ChooseAirport.jpf"),
+
+        // This action is raised by the ChooseAirport page flow  The navigateTo attribute here
+        // causes flow to return to the current page in this page flow.
+        @Jpf.SimpleAction(name="chooseAirportCancelled", navigateTo=Jpf.NavigateTo.currentPage)
+    }
+)
+public class Controller extends PageFlowController
+{
+    @Jpf.Action(
+        forwards={
+            @Jpf.Forward(
+                name="results",
+                path="results.jsp",
+                actionOutputs={
+                    @Jpf.ActionOutput(name="airport", type=String.class, required=true)
+                }
+            )
+        }
+    )
+    protected Forward chooseAirportDone( nesting.chooseairport.ChooseAirport.Results results )
+    {
+        Forward fwd = new Forward("results");
+        fwd.addActionOutput("airport", results.getAirport());
+        return fwd;
+    }
+}

Propchange: incubator/beehive/trunk/samples/netui-samples/nesting/Controller.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/ChooseAirport.java
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/ChooseAirport.java?rev=178353&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/ChooseAirport.java (added)
+++ incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/ChooseAirport.java Tue May 24 20:34:27 2005
@@ -0,0 +1,119 @@
+package nesting.chooseairport;
+
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+import java.io.Serializable;
+
+
+@Jpf.Controller(
+    nested=true,
+    simpleActions={
+        @Jpf.SimpleAction(name="begin", path="findairport.jsp"),
+
+        // This action returns to the original page flow, and raises the "chooseAirportCancelled"
+        // action.  It is run when the user presses the Cancel button on findairport.jsp or on
+        // confirm.jsp.
+        @Jpf.SimpleAction(name="cancelSearch", returnAction="chooseAirportCancelled"),
+
+        // This action runs when the user presses the OK button on confirm.jsp.  It returns to the
+        // nesting page flow, where it raises the "chooseAirportDone" action.
+        @Jpf.SimpleAction(
+            name="confirmResults",
+            returnAction="chooseAirportDone",
+            outputFormBean="_currentResults"
+        )
+    },
+    messageBundles={
+        @Jpf.MessageBundle(bundlePath="org.apache.beehive.samples.netui.resources.nesting.chooseairport")
+    }
+)
+public class ChooseAirport extends PageFlowController
+{
+    /**
+     * This is the bean that will be returned to the original page flow.
+     */
+    private Results _currentResults;
+
+    public Results getCurrentResults()
+    {
+        return _currentResults;
+    }
+
+    /**
+     * This action runs when the user presses the Search button on findairport.jsp.  It chooses
+     * an airport and forwards to the confirmation page.
+     *
+     * @jpf:action
+     * @jpf:forward name="confirm" path="confirm.jsp"
+     */
+    @Jpf.Action(
+        forwards={
+            @Jpf.Forward(name="confirm", path="confirm.jsp")
+        },
+        validationErrorForward=@Jpf.Forward(name="failure", navigateTo=Jpf.NavigateTo.currentPage)
+   )
+    protected Forward doSearch(SearchForm form)
+    {
+        // Pretend we're actually looking up an airport code...
+        _currentResults = new Results();
+        _currentResults.setAirport("Denver International Airport");
+        _currentResults.setAirportCode("DEN");
+
+        return new Forward("confirm");
+    }
+
+    /**
+     * This is the form bean that works with findairport.jsp.
+     */
+    public static class SearchForm
+        implements Serializable
+    {
+        private String _searchText;
+
+        @Jpf.ValidatableProperty(
+            displayNameKey="displayname.searchtext",
+            validateRequired=@Jpf.ValidateRequired()
+        )
+        public String getSearchText()
+        {
+            return _searchText;
+        }
+
+        public void setSearchText(String st)
+        {
+            _searchText = st;
+        }
+    }
+
+    /**
+     * This is the bean we'll return to the original page flow.
+     */
+    public static class Results
+        implements Serializable
+    {
+        private String _airport;
+        private String _airportCode;
+
+        public String getAirport()
+        {
+            return _airport;
+        }
+
+        public void setAirport(String airport)
+        {
+            _airport = airport;
+        }
+
+        public String getAirportCode()
+        {
+            return _airportCode;
+        }
+
+        public void setAirportCode(String code)
+        {
+            _airportCode = code;
+        }
+    }
+}

Propchange: incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/ChooseAirport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/confirm.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/confirm.jsp?rev=178353&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/confirm.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/confirm.jsp Tue May 24 20:34:27 2005
@@ -0,0 +1,40 @@
+<%--
+   Copyright 2004-2005 The Apache Software Foundation.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+   
+       http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  
+   $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
+<%@ taglib prefix="netui-data" uri="http://beehive.apache.org/netui/tags-databinding-1.0"%>
+<%@ taglib prefix="netui-template" uri="http://beehive.apache.org/netui/tags-template-1.0"%>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+
+    <netui-template:setAttribute name="samTitle" value="Nesting"/>
+
+    <netui-template:section name="main">
+        <h3>Choose Airport (nested page flow)</h3>
+
+        <netui:form action="confirmResults">
+            The closest match was <b>${pageFlow.currentResults.airport}</b>
+                (<b>${pageFlow.currentResults.airportCode}</b>).
+            <br/>
+            <br/>
+            <netui:button>OK</netui:button>
+            <netui:button action="cancelSearch">cancel</netui:button>
+        </netui:form>
+  </netui-template:section>
+
+</netui-template:template>

Propchange: incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/confirm.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/findairport.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/findairport.jsp?rev=178353&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/findairport.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/findairport.jsp Tue May 24 20:34:27 2005
@@ -0,0 +1,39 @@
+<%--
+   Copyright 2004-2005 The Apache Software Foundation.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+   
+       http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  
+   $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
+<%@ taglib prefix="netui-data" uri="http://beehive.apache.org/netui/tags-databinding-1.0"%>
+<%@ taglib prefix="netui-template" uri="http://beehive.apache.org/netui/tags-template-1.0"%>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+
+    <netui-template:setAttribute name="samTitle" value="Nesting"/>
+
+    <netui-template:section name="main">
+        <h3>Choose Airport (nested page flow)</h3>
+        <netui:form action="doSearch">
+            Airport city or name:
+            <netui:textBox dataSource="actionForm.searchText"/>
+            <netui:error key="searchText"/>
+            <br/>
+            <netui:button>OK</netui:button>
+            <netui:button action="cancelSearch">cancel</netui:button>
+        </netui:form>
+    </netui-template:section>
+
+</netui-template:template>

Propchange: incubator/beehive/trunk/samples/netui-samples/nesting/chooseairport/findairport.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/beehive/trunk/samples/netui-samples/nesting/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/nesting/index.jsp?rev=178353&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/nesting/index.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/nesting/index.jsp Tue May 24 20:34:27 2005
@@ -0,0 +1,44 @@
+<%--
+   Copyright 2004-2005 The Apache Software Foundation.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+   
+       http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  
+   $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
+<%@ taglib prefix="netui-data" uri="http://beehive.apache.org/netui/tags-databinding-1.0"%>
+<%@ taglib prefix="netui-template" uri="http://beehive.apache.org/netui/tags-template-1.0"%>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+
+    <netui-template:setAttribute name="samTitle" value="Nesting"/>
+
+    <netui-template:section name="main">
+        Clicking the link below launches the ChooseAirport nested page flow, which does one of two
+        things:
+        <ul>
+            <li>
+                Returns the 'chooseAirportDone' action, which carries a Results bean with it.  In
+                this case, we forward to a results page to display the returned data.
+            </li>
+            <li>
+                Returns the 'chooseAirportCancelled' action, in which case we just go back to the
+                current page.
+            </li>
+        </ul>
+        <br/>
+        <netui:anchor action="chooseAirport">Run the Choose Airport wizard</netui:anchor>
+    </netui-template:section>
+
+</netui-template:template>

Propchange: incubator/beehive/trunk/samples/netui-samples/nesting/index.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/beehive/trunk/samples/netui-samples/nesting/results.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/samples/netui-samples/nesting/results.jsp?rev=178353&view=auto
==============================================================================
--- incubator/beehive/trunk/samples/netui-samples/nesting/results.jsp (added)
+++ incubator/beehive/trunk/samples/netui-samples/nesting/results.jsp Tue May 24 20:34:27 2005
@@ -0,0 +1,36 @@
+<%--
+   Copyright 2004-2005 The Apache Software Foundation.
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+   
+       http://www.apache.org/licenses/LICENSE-2.0
+   
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  
+   $Header:$
+--%>
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
+<%@ taglib prefix="netui-data" uri="http://beehive.apache.org/netui/tags-databinding-1.0"%>
+<%@ taglib prefix="netui-template" uri="http://beehive.apache.org/netui/tags-template-1.0"%>
+
+<netui-data:declarePageInput name="airport" type="java.lang.String" required="true"/>
+
+<netui-template:template templatePage="/resources/template/template.jsp">
+
+  <netui-template:setAttribute name="samTitle" value="Nesting"/>
+
+  <netui-template:section name="main">
+        The airport you chose was <b>${pageInput.airport}</b>.
+        <br/>
+        <br/>
+        <netui:anchor action="begin">start over</netui:anchor>
+  </netui-template:section>
+
+</netui-template:template>

Propchange: incubator/beehive/trunk/samples/netui-samples/nesting/results.jsp
------------------------------------------------------------------------------
    svn:eol-style = native