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/20 20:40:33 UTC
svn commit: r358081 - in /beehive/trunk/samples/system-controls-jdbc: ./
src/ src/controls/ src/shared/ src/sql/ web/ web/WEB-INF/
Author: steveh
Date: Tue Dec 20 11:39:41 2005
New Revision: 358081
URL: http://svn.apache.org/viewcvs?rev=358081&view=rev
Log:
Latest version of the jdbc system-control sample.
In this revision:
(1) SQL statements have been moved into an init.sql file.
(2) Page inputs have been added to all JSP pages.
Yet to do:
(1) Add sample to the distribution.
(2) Set up the database with a DataSource rather than a connection URL.
(3) Add transaction support and other system controls.
Added:
beehive/trunk/samples/system-controls-jdbc/
beehive/trunk/samples/system-controls-jdbc/README.txt (with props)
beehive/trunk/samples/system-controls-jdbc/build.properties (with props)
beehive/trunk/samples/system-controls-jdbc/build.xml (with props)
beehive/trunk/samples/system-controls-jdbc/src/
beehive/trunk/samples/system-controls-jdbc/src/controls/
beehive/trunk/samples/system-controls-jdbc/src/controls/PopulateDBCtrl.java (with props)
beehive/trunk/samples/system-controls-jdbc/src/controls/SimpleDBControl.java (with props)
beehive/trunk/samples/system-controls-jdbc/src/log4j.xml (with props)
beehive/trunk/samples/system-controls-jdbc/src/shared/
beehive/trunk/samples/system-controls-jdbc/src/shared/SharedFlow.java (with props)
beehive/trunk/samples/system-controls-jdbc/src/sql/
beehive/trunk/samples/system-controls-jdbc/src/sql/initDB.sql
beehive/trunk/samples/system-controls-jdbc/web/
beehive/trunk/samples/system-controls-jdbc/web/Controller.java (with props)
beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/
beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/beehive-netui-validator-rules.xml (with props)
beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/validator-rules.xml (with props)
beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/web.xml (with props)
beehive/trunk/samples/system-controls-jdbc/web/demo.jsp (with props)
beehive/trunk/samples/system-controls-jdbc/web/details.jsp (with props)
beehive/trunk/samples/system-controls-jdbc/web/index.jsp (with props)
beehive/trunk/samples/system-controls-jdbc/web/sql.jsp (with props)
Added: beehive/trunk/samples/system-controls-jdbc/README.txt
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/README.txt?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/README.txt (added)
+++ beehive/trunk/samples/system-controls-jdbc/README.txt Tue Dec 20 11:39:41 2005
@@ -0,0 +1,30 @@
+To run this sample, following these steps:
+
+(1) Complete the required and optional steps in the topic: http://beehive.apache.org/docs/1.0/tutorial/setup.html
+
+(2) Download the latest version of derby and copy derby.jar to $CATALINA_HOME/common/lib
+
+(3) Configure Tomcat
+
+ [todo: still working on getting a working Tomcat configuration]
+
+(4) Configure the web app
+
+Add the following to your apps WEB-INF/web.xml file. Position it immediately before the </web-app> tag:
+
+ <resource-ref>
+ <description>DB Connection</description>
+ <res-ref-name>jdbc/JdbcControlSampleDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+(5) Edit /system-controls-jdbc/build.properties so that beehive.home points to the top level folder of your beehive installation.
+
+(6) Start Tomcat $CATALINA_HOME/bin/startup.bat
+
+(7) cd to /system-controls-jdbc and run: ant clean build war
+
+(8) cp jdbcControlSample.war $CATALINA_HOME/webapps
+
+(9) visit: http://localhost:8080/jdbcControlSample/Controller.jpf
Propchange: beehive/trunk/samples/system-controls-jdbc/README.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/build.properties
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/build.properties?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/build.properties (added)
+++ beehive/trunk/samples/system-controls-jdbc/build.properties Tue Dec 20 11:39:41 2005
@@ -0,0 +1,9 @@
+#
+#
+#
+beehive.home=../../
+
+servlet-api.jar=${os.CATALINA_HOME}/common/lib/servlet-api.jar
+jsp-api.jar=${os.CATALINA_HOME}/common/lib/jsp-api.jar
+
+context.path=jdbcControlSample
Propchange: beehive/trunk/samples/system-controls-jdbc/build.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/build.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/build.xml?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/build.xml (added)
+++ beehive/trunk/samples/system-controls-jdbc/build.xml Tue Dec 20 11:39:41 2005
@@ -0,0 +1,145 @@
+<?xml version="1.0"?>
+<!--
+ 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:$
+ -->
+
+<!--
+ An Ant build file for compiling a Beehive page flow web application.
+-->
+<project name="Beehive/Samples/jdbcControlSample" default="usage" basedir=".">
+
+ <property environment="os"/>
+ <property file="${basedir}/build.properties"/>
+
+ <import file="${beehive.home}/beehive-imports.xml"/>
+ <import file="${beehive.home}/ant/beehive-tools.xml"/>
+
+ <property name="webapp.dir" location="${basedir}"/>
+ <property name="build.dir" location="build"/>
+ <property name="web.dir" location="web"/>
+ <property name="src.dir" location="src"/>
+
+ <property name="tmp.sourcegen.dir" value=".tmpbeansrc"/>
+
+ <!-- Define the classpath used to build the webapp -->
+ <path id="webapp.classpath">
+ <pathelement location="${servlet-api.jar}"/>
+ <pathelement location="${jsp-api.jar}"/>
+ <pathelement location="${build.dir}/WEB-INF/classes"/>
+ <fileset dir="${build.dir}/WEB-INF/lib">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <path id="webapp.sourcepath">
+ <pathelement location="${web.dir}"/>
+ <pathelement location="${src.dir}"/>
+ </path>
+
+ <target name="deploy-beehive" description="Copy the Beehive Page Flow rutime into the target webapp">
+ <mkdir dir="${build.dir}"/>
+ <deploy-netui webappDir="${build.dir}"/>
+ <!-- Needs the beehive-jdbc-controls.jar to work. -->
+ <copy todir="${build.dir}/WEB-INF/lib" file="${beehive.home}/lib/controls/beehive-jdbc-control.jar"></copy>
+ </target>
+
+ <target name="build" depends="deploy-beehive" description="Build the webapp">
+ <available property="webapp.dir.available" file="${webapp.dir}" type="dir"/>
+ <fail unless="webapp.dir.available" message="Can't find the webapp directory ${webapp.dir}"/>
+
+ <copy todir="${build.dir}/">
+ <fileset dir="${web.dir}">
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+
+ <copy todir="${build.dir}/WEB-INF/classes">
+ <fileset dir="${src.dir}/">
+ <include name="sql/**"/>
+ <include name="**/*.properties"/>
+ <include name="**/*.xml"/>
+ </fileset>
+ </copy>
+
+ <!-- compile controls -->
+ <echo>Building Controls</echo>
+ <build-controls srcdir="${basedir}/src"
+ destdir="${build.dir}/WEB-INF/classes"
+ tempdir="${build.dir}/WEB-INF/${tmp.sourcegen.dir}"
+ classpathRef="webapp.classpath"/>
+
+ <!-- compile JPFs -->
+ <echo>Building Page Flows</echo>
+ <build-pageflows srcdir="${basedir}"
+ webcontentdir="${web.dir}"
+ destdir="${build.dir}/WEB-INF/classes"
+ tempdir="${build.dir}/WEB-INF/${tmp.sourcegen.dir}"
+ sourcepathref="webapp.sourcepath"
+ classpathref="webapp.classpath"/>
+
+ <!-- copy resources -->
+ <echo>Copy all .properties and .xml files</echo>
+ <copy todir="${build.dir}/WEB-INF/classes">
+ <fileset dir="${src.dir}" includes="**/*.properties"/>
+ <fileset dir="${src.dir}" includes="**/*.xml"/>
+ </copy>
+ </target>
+
+ <target name="copy.jsps"
+ description="When deploying an exploded webapp, this target copies changed JSPs into the deployed directory">
+ <copy todir="${build.dir}/">
+ <fileset dir="${web.dir}">
+ <exclude name="**/*.java"/>
+ <exclude name="WEB-INF/**"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="clean" description="Clean the webapp">
+ <delete dir="${build.dir}" includeEmptyDirs="true"/>
+ <delete file="${basedir}/${context.path}.war" />
+ </target>
+
+ <target name="war" description="Build a compressed WAR file that can be deployed to an application container">
+ <property name="archive.dir" value="${basedir}"/>
+
+ <!-- this does *not* exclude source from the archive -->
+ <war destfile="${archive.dir}/${context.path}.war" webxml="${build.dir}/WEB-INF/web.xml">
+ <fileset dir="${build.dir}">
+ <exclude name="WEB-INF/web.xml"/>
+ </fileset>
+ <!--<metainf dir="${basedir}/META-INF">
+
+ </metainf>-->
+ </war>
+ </target>
+
+ <target name="usage" description="Print usage information for this build file">
+ <echo>
+To run the webapp, two steps need to occur:
+- copy the Beehive runtime to the webapp
+- build the webapp
+
+Once the webapp is built, it's ready to deploy onto your application container.
+ </echo>
+
+ <java fork="no" classname="org.apache.tools.ant.Main">
+ <arg line="-f ${ant.file} -projecthelp"/>
+ </java>
+ </target>
+
+</project>
Propchange: beehive/trunk/samples/system-controls-jdbc/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/src/controls/PopulateDBCtrl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/src/controls/PopulateDBCtrl.java?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/src/controls/PopulateDBCtrl.java (added)
+++ beehive/trunk/samples/system-controls-jdbc/src/controls/PopulateDBCtrl.java Tue Dec 20 11:39:41 2005
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2004 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:$
+ */
+package controls;
+
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import org.apache.beehive.controls.system.jdbc.JdbcControl;
+
+/**
+ * This Jdbc Control is used to populate the sample database.
+
+@JdbcControl.ConnectionDataSource(jndiName="java:comp/env/jdbc/JdbcControlSampleDB")
+
+ *
+ */
+@org.apache.beehive.controls.api.bean.ControlExtension
+@JdbcControl.ConnectionDriver(databaseDriverClass="org.apache.derby.jdbc.EmbeddedDriver",
+ databaseURL="jdbc:derby:C:/apache/derby/jdbcSample/JdbcControlSampleDB;create=true")
+public interface PopulateDBCtrl extends JdbcControl
+{
+ /**
+ * Create the products table in the database.
+ */
+ @JdbcControl.SQL(statement="CREATE TABLE products (name VARCHAR(64), description VARCHAR(128), quantity INT)")
+ public void createProductsTable() throws SQLException;
+
+ /**
+ * Add a row to the products table.
+ * @param name String
+ * @param description String
+ * @param quantity int
+ */
+ @JdbcControl.SQL(statement="INSERT INTO products VALUES ({name}, {description}, {quantity})")
+ public void addProductRow(String name, String description, int quantity) throws SQLException;
+
+ /**
+ * Returns the number of rows in the products table.
+ * @return
+ */
+ @JdbcControl.SQL(statement="SELECT name FROM products WHERE name='apple'")
+ public String isProductsTableEmpty() throws SQLException;
+
+ /**
+ * Returns the number of rows in the products table.
+ * @return
+ */
+ @JdbcControl.SQL(statement="{sql: sqlString}")
+ public void initDB(String sqlString) throws SQLException;
+
+ static final long serialVersionUID = 1L;
+}
Propchange: beehive/trunk/samples/system-controls-jdbc/src/controls/PopulateDBCtrl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/src/controls/SimpleDBControl.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/src/controls/SimpleDBControl.java?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/src/controls/SimpleDBControl.java (added)
+++ beehive/trunk/samples/system-controls-jdbc/src/controls/SimpleDBControl.java Tue Dec 20 11:39:41 2005
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2004 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:$
+ */
+package controls;
+
+import java.sql.SQLException;
+import java.sql.ResultSet;
+import org.apache.beehive.controls.system.jdbc.JdbcControl;
+
+/**
+ * JdbcControl implementation for the JdbcControl sample app.
+ *
+ *
+ * The following @JdbcControl.ConnectionDriver works
+ * @JdbcControl.ConnectionDriver(databaseDriverClass="org.apache.derby.jdbc.EmbeddedDriver",
+ * databaseURL="jdbc:derby:c:/Apache/Derby/jdbcSample/jdbcSampleDB;create=true")
+ *
+ *
+@JdbcControl.ConnectionDataSource(jndiName="java:comp/env/jdbc/JdbcControlSampleDB")
+ *
+ *
+ */
+@org.apache.beehive.controls.api.bean.ControlExtension
+@JdbcControl.ConnectionDriver(databaseDriverClass="org.apache.derby.jdbc.EmbeddedDriver",
+ databaseURL="jdbc:derby:C:/apache/derby/jdbcSample/JdbcControlSampleDB;create=true")
+public interface SimpleDBControl extends JdbcControl
+{
+
+ static public class Product
+ {
+ private String _name;
+ private String _description;
+ private int _quantity;
+
+ public int getQuantity() { return _quantity; }
+ public void setQuantity(int i) { _quantity = i; }
+
+ public String getName() { return _name; }
+ public void setName(String n) { _name = n; }
+
+ public String getDescription() { return _description; }
+ public void setDescription(String n) { _description = n; }
+ }
+
+ /**
+ * Get the name column from the products table.
+ * @return An array of strings.
+ */
+ @JdbcControl.SQL(statement="SELECT name FROM products")
+ public String[] getProductNames() throws SQLException;
+
+ /**
+ * Get the rest of the columns associated with a product name.
+ * @param productName Name of product to lookup.
+ * @return An instance of Product.
+ */
+ @JdbcControl.SQL(statement="SELECT * FROM products WHERE name={productName}")
+ public Product getProductDetails(String productName) throws SQLException;
+
+ static final long serialVersionUID = 1L;
+}
Propchange: beehive/trunk/samples/system-controls-jdbc/src/controls/SimpleDBControl.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/src/log4j.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/src/log4j.xml?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/src/log4j.xml (added)
+++ beehive/trunk/samples/system-controls-jdbc/src/log4j.xml Tue Dec 20 11:39:41 2005
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="BEEHIVE_FILE_LOG" class="org.apache.log4j.RollingFileAppender">
+ <param name="File" value="beehive.log"/>
+ <param name="Append" value="true"/>
+ <param name="MaxFileSize" value="500000KB"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1} [%x]: %m%n"/>
+ </layout>
+ </appender>
+
+ <appender name="BEEHIVE_CONSOLE_LOG" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{DATE} %-5p %-15c{1} [%x]: %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- Beehive -->
+ <category name="org.apache.beehive">
+ <priority value="warn"/>
+ <appender-ref ref="BEEHIVE_CONSOLE_LOG"/>
+ </category>
+
+ <!-- NetUI Script: this allows separate configuration of script error reporting -->
+ <category name="org.apache.beehive.netui.script">
+ <priority value="error"/>
+ <appender-ref ref="BEEHIVE_CONSOLE_LOG"/>
+ </category>
+
+ <!-- Struts -->
+ <category name="org.apache.struts">
+ <priority value="warn"/>
+ <appender-ref ref="BEEHIVE_CONSOLE_LOG"/>
+ </category>
+
+ <!-- Jakarta Commons -->
+ <category name="org.apache.commons">
+ <priority value="warn"/>
+ <appender-ref ref="BEEHIVE_CONSOLE_LOG"/>
+ </category>
+
+</log4j:configuration>
Propchange: beehive/trunk/samples/system-controls-jdbc/src/log4j.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/src/shared/SharedFlow.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/src/shared/SharedFlow.java?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/src/shared/SharedFlow.java (added)
+++ beehive/trunk/samples/system-controls-jdbc/src/shared/SharedFlow.java Tue Dec 20 11:39:41 2005
@@ -0,0 +1,104 @@
+/*
+ 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:$
+*/
+package shared;
+
+import java.io.IOException;
+
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.PageFlowException;
+import org.apache.beehive.netui.pageflow.SharedFlowController;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
+/**
+ * This shared flow can define actions, exception handlers, and state to be shared among page flows
+ * that reference it. A page flow references this shared flow inside a <code>Jpf.Controller</code>
+ * annotation as:
+ * <pre>
+ * sharedFlowRefs={
+ * @Jpf.SharedFlowRef(name="shared", type=shared.SharedFlow.class)
+ * }
+ * </pre>
+ *
+ * Once referenced, the following features apply:
+ * <ul>
+ * <li>
+ * An instance of this shared flow will be created and stored the first time the page
+ * flow is accessed.
+ * </li>
+ * <li>
+ * The page flow (or its pages) can reference actions using the pattern
+ * <i>shared-flow-name.action-name</i>, e.g., "shared.someAction".
+ * </li>
+ * <li>
+ * Unhandled exceptions in the page flow will be handled by <code>Jpf.Catch</code>
+ * annotations in this shared flow.
+ * </li>
+ * <li>
+ * In pages and annotations that bind to data using the expression language, properties
+ * in this shared flow are accessed through the <code>sharedFlow</code> binding context.
+ * </li>
+ * <li>
+ * A page flow can have an automatically-initialized member reference to this shared
+ * flow using the <code>Jpf.SharedFlowField</code> annotation, like this:
+ * <pre>
+ * @Jpf.SharedFlowField(name="shared")
+ * private shared.SharedFlow _mySharedFlowReference;
+ * </pre>
+ * This is optional; it is useful if you need a hard reference to the shared flow
+ * controller.
+ * </li>
+ * </ul>
+ */
+@Jpf.Controller(
+ catches={
+ @Jpf.Catch(type=PageFlowException.class, method="handlePageFlowException"),
+ @Jpf.Catch(type=Exception.class, method="handleException")
+ }
+)
+public class SharedFlow
+ extends SharedFlowController
+{
+ @Jpf.ExceptionHandler(
+ forwards={
+ @Jpf.Forward(name="errorPage", path="/resources/beehive/version1/jsps/error.jsp")
+ }
+ )
+ protected Forward handleException(Exception ex, String actionName, String message, Object form)
+ {
+ System.err.print("[" + getRequest().getContextPath() + "] ");
+ System.err.println("Unhandled exception caught in shared flow " + getDisplayName() + ":");
+ ex.printStackTrace();
+ return new Forward("errorPage");
+ }
+
+ /**
+ * Handler for native page flow exceptions (e.g., ActionNotFoundException, which is thrown when
+ * an unknown page flow action is requested). This handler allows these exceptions to write
+ * informative error pages to the response when the server is not in production mode, and it
+ * allows them to send an appropriate error on the response when the server is in production
+ * mode. To use the standard exception handler for these exceptions, simply remove this method
+ * and the <code>Jpf.Catch</code> annotation that references it.
+ */
+ @Jpf.ExceptionHandler
+ public Forward handlePageFlowException(PageFlowException ex, String actionName, String message, Object form)
+ throws IOException
+ {
+ ex.sendError(getRequest(), getResponse());
+ return null;
+ }
+}
Propchange: beehive/trunk/samples/system-controls-jdbc/src/shared/SharedFlow.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/src/sql/initDB.sql
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/src/sql/initDB.sql?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/src/sql/initDB.sql (added)
+++ beehive/trunk/samples/system-controls-jdbc/src/sql/initDB.sql Tue Dec 20 11:39:41 2005
@@ -0,0 +1,33 @@
+-- Copyright 2001-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.
+
+-- Drop existing tables in proper order
+drop table products;
+
+-- Create tables in proper order
+CREATE TABLE products (name VARCHAR(64), description VARCHAR(128), quantity INT);
+
+-- Derby Specific Statements
+-- Place statements here
+
+-- PostgreSQL Specific Statements
+-- Place statements here
+
+-- Add data to tables
+INSERT INTO products VALUES ('apple', 'red apples', 200);
+INSERT INTO products VALUES ('orange', 'orange oranges', 400);
+INSERT INTO products VALUES ('kiwi', 'green with black seeds', 800);
+INSERT INTO products VALUES ('banana', 'yellow bananas', 123);
+INSERT INTO products VALUES ('coconut', 'coconutty', 21);
+INSERT INTO products VALUES ('plum', 'purple plums', 999);
\ No newline at end of file
Added: beehive/trunk/samples/system-controls-jdbc/web/Controller.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/web/Controller.java?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/web/Controller.java (added)
+++ beehive/trunk/samples/system-controls-jdbc/web/Controller.java Tue Dec 20 11:39:41 2005
@@ -0,0 +1,191 @@
+import javax.servlet.http.HttpSession;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.util.LinkedList;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+import org.apache.beehive.controls.api.bean.Control;
+import controls.SimpleDBControl;
+import controls.PopulateDBCtrl;
+import shared.SharedFlow;
+
+@Jpf.Controller(
+ simpleActions={},
+ sharedFlowRefs={
+ @Jpf.SharedFlowRef(name="shared", type=shared.SharedFlow.class)
+ }
+)
+public class Controller
+ extends PageFlowController
+{
+ private static final String SQL_FILE = "sql/initDB.sql";
+
+ @Jpf.SharedFlowField(name="shared")
+ private shared.SharedFlow sharedFlow;
+
+ // initialize the SimpleDBCtrl
+ @Control()
+ private SimpleDBControl _simpleDbCtrl;
+
+ // initialize the PopulateDBCtrl
+ @Control()
+ private PopulateDBCtrl _popCtrl;
+
+ public transient String[] productNames;
+ public transient SimpleDBControl.Product productDetails;
+
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="success", path="index.jsp")
+ }
+ )
+ protected Forward begin() {
+ return new Forward("success");
+ }
+
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="success", path="demo.jsp",
+ actionOutputs = {
+ @Jpf.ActionOutput(name = "products",
+ type = String[].class,
+ required = true)
+ })
+ }
+ )
+ protected Forward startDemo() throws SQLException {
+
+ productNames = _simpleDbCtrl.getProductNames();
+ Forward f = new Forward("success");
+ f.addActionOutput("products", productNames);
+ return f;
+ }
+
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="success", path="details.jsp",
+ actionOutputs = {
+ @Jpf.ActionOutput(name = "details",
+ type = controls.SimpleDBControl.Product.class,
+ required = true)
+ })
+ }
+ )
+ protected Forward productDetails() throws SQLException {
+
+ productDetails = _simpleDbCtrl.getProductDetails(getRequest().getParameter("key"));
+ Forward f = new Forward("success");
+ f.addActionOutput("details", productDetails);
+ return f;
+ }
+
+ /**
+ * Callback that is invoked when this controller instance is created.
+ */
+ protected void onCreate()
+ {
+ /*
+ try {
+ Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+ } catch (ClassNotFoundException e) {
+ System.out.println("JdbcSampleApp: Class Not Found: " + e);
+ return;
+ }
+
+ System.out.println("jdbcControlSample: checking to see if products table exists...");
+ try {
+ check = _popCtrl.isProductsTableEmpty();
+ } catch (SQLException sqe) {
+ }
+
+ // table has been loaded -- just return
+ if (check != null) {
+ System.out.println("jdbcControlSample: products table exists.");
+ return;
+ }
+ */
+
+ System.out.println("jdbcControlSample: creating sample tables...");
+ try {
+
+ initDB();
+ /*
+ _popCtrl.createProductsTable();
+ _popCtrl.addProductRow("apple", "red apples", 200);
+ _popCtrl.addProductRow("orange", "orange oranges", 400);
+ _popCtrl.addProductRow("kiwi", "lots of kiwi", 800);
+ _popCtrl.addProductRow("banana", "yellow", 123);
+ _popCtrl.addProductRow("coconut", "coconutty", 21);
+ _popCtrl.addProductRow("plum", "lots of plums", 999);*/
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Jpf.Action
+ public Forward initDB()
+ throws Exception {
+ LinkedList<String> dbInit = getSqlStatements(SQL_FILE);
+
+ for(String sql : dbInit) {
+ try {
+ _popCtrl.initDB(sql);
+ }
+ catch(Exception e) {
+ // Ignore exceptions on DROP statements since the tables may simply not exist
+ if (!sql.startsWith("drop"))
+ throw e;
+ }
+ }
+ getRequest().setAttribute("message", "DB Initialized.");
+
+ return new Forward("index");
+ }
+
+private LinkedList<String> getSqlStatements(String sqlFile)
+ throws Exception {
+
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(sqlFile);
+ BufferedReader fs = new BufferedReader(new InputStreamReader(is));
+ LinkedList<String> statements = new LinkedList<String>();
+ try {
+ String line = null;
+ while((line = fs.readLine()) != null)
+ {
+ // Ignore comments and empty lines
+ if (line.endsWith(";") && !(line.startsWith("--")))
+ statements.add(line.replace(';', ' '));
+ }
+ }
+ catch(IOException io) {
+ throw new IllegalStateException("Unable to read input stream: " + sqlFile);
+ }
+ finally {
+ try {
+ if(fs != null) fs.close();
+ } catch(Exception ignore) {}
+ }
+
+ for(String s : statements) {
+ System.out.println(s + "\n");
+ }
+
+ return statements;
+}
+
+
+ /**
+ * Callback that is invoked when this controller instance is destroyed.
+ */
+ protected void onDestroy(HttpSession session)
+ {
+ }
+}
Propchange: beehive/trunk/samples/system-controls-jdbc/web/Controller.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/beehive-netui-validator-rules.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/beehive-netui-validator-rules.xml?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/beehive-netui-validator-rules.xml (added)
+++ beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/beehive-netui-validator-rules.xml Tue Dec 20 11:39:41 2005
@@ -0,0 +1,38 @@
+<!DOCTYPE form-validation PUBLIC
+ "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
+ "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd">
+<!--
+ This file contains the default NetUI validator definitions. It should be
+ placed in /WEB-INF, and is automatically referenced in Struts config files
+ generated by the Page Flow compiler.
+-->
+
+<form-validation>
+
+ <global>
+
+ <validator name="netui_validwhen"
+ classname="org.apache.beehive.netui.pageflow.validation.ValidatorRules"
+ method="validateValidWhen"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ javax.servlet.http.HttpServletRequest,
+ javax.servlet.ServletContext"
+ msg="errors.netui_validwhen"/>
+
+ <validator name="netui_longRange"
+ classname="org.apache.beehive.netui.pageflow.validation.ValidatorRules"
+ method="validateLongRange"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ javax.servlet.http.HttpServletRequest"
+ depends="long"
+ msg="errors.range"/>
+
+ </global>
+
+</form-validation>
Propchange: beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/beehive-netui-validator-rules.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/validator-rules.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/validator-rules.xml?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/validator-rules.xml (added)
+++ beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/validator-rules.xml Tue Dec 20 11:39:41 2005
@@ -0,0 +1,313 @@
+<!DOCTYPE form-validation PUBLIC
+ "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.1.3//EN"
+ "http://jakarta.apache.org/commons/dtds/validator_1_1_3.dtd">
+<!--
+ $Id: validator-rules.xml 159291 2005-03-28 20:19:29Z niallp $
+
+ This file contains the default Struts Validator pluggable validator
+ definitions. It should be placed somewhere under /WEB-INF and
+ referenced in the struts-config.xml under the plug-in element
+ for the ValidatorPlugIn.
+
+ <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
+ <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
+ /WEB-INF/validation.xml"/>
+ </plug-in>
+
+ These are the default error messages associated with
+ each validator defined in this file. They should be
+ added to your projects ApplicationResources.properties
+ file or you can associate new ones by modifying the
+ pluggable validators msg attributes in this file.
+
+ # Struts Validator Error Messages
+ errors.required={0} is required.
+ errors.minlength={0} can not be less than {1} characters.
+ errors.maxlength={0} can not be greater than {1} characters.
+ errors.invalid={0} is invalid.
+
+ errors.byte={0} must be a byte.
+ errors.short={0} must be a short.
+ errors.integer={0} must be an integer.
+ errors.long={0} must be a long.
+ errors.float={0} must be a float.
+ errors.double={0} must be a double.
+
+ errors.date={0} is not a date.
+ errors.range={0} is not in the range {1} through {2}.
+ errors.creditcard={0} is an invalid credit card number.
+ errors.email={0} is an invalid e-mail address.
+
+ Note: Starting in Struts 1.2.0 the default javascript definitions have
+ been consolidated to commons-validator. The default can be overridden
+ by supplying a <javascript> element with a CDATA section, just as
+ in struts 1.1.
+
+-->
+
+<form-validation>
+
+ <global>
+
+ <validator name="required"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateRequired"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ msg="errors.required"/>
+
+ <validator name="requiredif"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateRequiredIf"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ msg="errors.required"/>
+
+ <validator name="validwhen"
+ msg="errors.required"
+ classname="org.apache.struts.validator.validwhen.ValidWhen"
+ method="validateValidWhen"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"/>
+
+
+ <validator name="minlength"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateMinLength"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.minlength"
+ jsFunction="org.apache.commons.validator.javascript.validateMinLength"/>
+
+
+ <validator name="maxlength"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateMaxLength"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.maxlength"
+ jsFunction="org.apache.commons.validator.javascript.validateMaxLength"/>
+
+
+
+ <validator name="mask"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateMask"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.invalid"/>
+
+
+ <validator name="byte"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateByte"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.byte"
+ jsFunctionName="ByteValidations"/>
+
+
+ <validator name="short"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateShort"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.short"
+ jsFunctionName="ShortValidations"/>
+
+
+ <validator name="integer"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateInteger"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.integer"
+ jsFunctionName="IntegerValidations"/>
+
+
+
+ <validator name="long"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateLong"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.long"/>
+
+
+ <validator name="float"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateFloat"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.float"
+ jsFunctionName="FloatValidations"/>
+
+ <validator name="double"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateDouble"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.double"/>
+
+
+ <validator name="date"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateDate"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.date"
+ jsFunctionName="DateValidations"/>
+
+
+ <validator name="intRange"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateIntRange"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends="integer"
+ msg="errors.range"/>
+
+
+ <validator name="floatRange"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateFloatRange"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends="float"
+ msg="errors.range"/>
+
+ <validator name="doubleRange"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateDoubleRange"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends="double"
+ msg="errors.range"/>
+
+
+ <validator name="creditCard"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateCreditCard"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.creditcard"/>
+
+
+ <validator name="email"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateEmail"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.email"/>
+
+ <validator name="url"
+ classname="org.apache.struts.validator.FieldChecks"
+ method="validateUrl"
+ methodParams="java.lang.Object,
+ org.apache.commons.validator.ValidatorAction,
+ org.apache.commons.validator.Field,
+ org.apache.struts.action.ActionMessages,
+ org.apache.commons.validator.Validator,
+ javax.servlet.http.HttpServletRequest"
+ depends=""
+ msg="errors.url"/>
+
+ <!--
+ This simply allows struts to include the validateUtilities into a page, it should
+ not be used as a validation rule.
+ -->
+ <validator name="includeJavaScriptUtilities"
+ classname=""
+ method=""
+ methodParams=""
+ depends=""
+ msg=""
+ jsFunction="org.apache.commons.validator.javascript.validateUtilities"/>
+
+ </global>
+
+</form-validation>
Propchange: beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/validator-rules.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/web.xml
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/web.xml?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/web.xml (added)
+++ beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/web.xml Tue Dec 20 11:39:41 2005
@@ -0,0 +1,146 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+
+ <display-name>Beehive Web Application</display-name>
+
+ <!-- Filter to perform Page Flow operations when JSPs are hit directly. -->
+ <filter>
+ <filter-name>PageFlowJspFilter</filter-name>
+ <filter-class>org.apache.beehive.netui.pageflow.PageFlowJspFilter</filter-class>
+ </filter>
+
+ <!-- Filter to perform Page Flow operations when JavaServer Faces pages are hit directly. -->
+ <filter>
+ <filter-name>PageFlowFacesFilter</filter-name>
+ <filter-class>org.apache.beehive.netui.pageflow.PageFlowFacesFilter</filter-class>
+ </filter>
+
+ <!--
+ It is possible - but certainly not required - to keep source files such as page flows and
+ JavaServer Faces backing beans mixed in with web content. In this case, and when the web
+ content directory itself is being deployed without being copied to some other build
+ location, it is important to prevent the source code from being URL-addressable. This
+ filter returns a specified error code when source files are requested.
+ -->
+ <filter>
+ <filter-name>PageFlowForbiddenFilter</filter-name>
+ <filter-class>org.apache.beehive.netui.pageflow.PageFlowForbiddenFilter</filter-class>
+ <init-param>
+ <param-name>response-code</param-name>
+ <param-value>404</param-value>
+ </init-param>
+ </filter>
+
+ <filter-mapping>
+ <filter-name>PageFlowJspFilter</filter-name>
+ <url-pattern>*.jsp</url-pattern>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>PageFlowJspFilter</filter-name>
+ <url-pattern>*.jspx</url-pattern>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>PageFlowFacesFilter</filter-name>
+ <url-pattern>*.faces</url-pattern>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <filter-mapping>
+ <filter-name>PageFlowFacesFilter</filter-name>
+ <url-pattern>*.jsf</url-pattern>
+ <dispatcher>FORWARD</dispatcher>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
+ <!-- Prevent URL access to Java source code. -->
+ <filter-mapping>
+ <filter-name>PageFlowForbiddenFilter</filter-name>
+ <url-pattern>*.java</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ </filter-mapping>
+
+ <!-- Prevent URL access to JavaServer Faces backing beans. -->
+ <filter-mapping>
+ <filter-name>PageFlowForbiddenFilter</filter-name>
+ <url-pattern>*.jsfb</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ </filter-mapping>
+
+ <!-- Prevent URL access to shared flow source files. -->
+ <filter-mapping>
+ <filter-name>PageFlowForbiddenFilter</filter-name>
+ <url-pattern>*.jpfs</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ </filter-mapping>
+
+ <!-- Action Servlet Configuration (with debugging) -->
+ <servlet>
+ <servlet-name>action</servlet-name>
+ <servlet-class>org.apache.beehive.netui.pageflow.PageFlowActionServlet</servlet-class>
+ <init-param>
+ <param-name>config</param-name>
+ <param-value>/_pageflow/struts-config.xml</param-value>
+ </init-param>
+ <init-param>
+ <param-name>debug</param-name>
+ <param-value>2</param-value>
+ </init-param>
+ <init-param>
+ <param-name>detail</param-name>
+ <param-value>2</param-value>
+ </init-param>
+ <load-on-startup>2</load-on-startup>
+ </servlet>
+
+ <!-- The XmlHttpRequest handler Servlet -->
+ <servlet>
+ <servlet-name>XmlHttpRequestServlet</servlet-name>
+ <servlet-class>org.apache.beehive.netui.pageflow.xmlhttprequest.XmlHttpRequestServlet</servlet-class>
+ </servlet>
+
+ <!-- Struts Action Servlet Mappings -->
+ <!-- Note that because Struts takes the *last* mapping here as the extension to add to
+ actions posted from forms, we must have *.do come after *.jpf (etc.). -->
+ <servlet-mapping>
+ <servlet-name>action</servlet-name>
+ <url-pattern>*.jpf</url-pattern>
+ </servlet-mapping>
+
+ <servlet-mapping>
+ <servlet-name>action</servlet-name>
+ <url-pattern>*.do</url-pattern>
+ </servlet-mapping>
+
+ <!-- XmlHttpRequest Servlet -->
+ <servlet-mapping>
+ <servlet-name>XmlHttpRequestServlet</servlet-name>
+ <url-pattern>*.xhr</url-pattern>
+ </servlet-mapping>
+
+ <welcome-file-list>
+ <welcome-file>index.jsp</welcome-file>
+ </welcome-file-list>
+
+ <!--<resource-ref>
+ <description>DB Connection</description>
+ <res-ref-name>jdbc/JdbcControlSampleDB</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>-->
+
+</web-app>
Propchange: beehive/trunk/samples/system-controls-jdbc/web/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/web/demo.jsp
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/web/demo.jsp?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/web/demo.jsp (added)
+++ beehive/trunk/samples/system-controls-jdbc/web/demo.jsp Tue Dec 20 11:39:41 2005
@@ -0,0 +1,71 @@
+<%@ 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>JspControlApp Sample Application</title>
+ <netui:base/>
+ <style>
+
+.datagrid-header{
+ background-color: #eeeeee;
+}
+.datagrid-header-cel{
+ background-color: #f0f0f0;
+}
+.custom-datagrid-header-cell{
+ background-color: #0f0f0f;
+}
+.datagrid-data-cell{
+}
+.datagrid-even{
+ background-color: #ffffff;
+}
+.datagrid-even a {
+ text-decoration: none;
+ color: #000000;
+}
+.datagrid-odd{
+ background-color: #ffffde;
+}
+.datagrid-odd a {
+ text-decoration: none;
+ color: #000000;
+}
+ </style>
+ </head>
+
+ <netui:body>
+
+ <h1>JdbcControl Sample</h1>
+ <p></p>
+ <p>This is a tiny sample application which uses a JdbcControl inside of a Beehive PageFlow. When
+ this page is accessed for the first time, a small Derby database is created and populated by the
+ JdbcControl PopulateDBCtrl.</p>
+
+ <p>The data grid of product names below has been provided by the SimpleJdbcCtrl's getProductNames()
+ method. Clicking in the second column will trigger another call to the SimpleJdbcCtrl to get
+ more detailed information from the database for the selected item.</p>
+
+ <netui-data:dataGrid dataSource="pageInput.products" name="productNameGrid">
+ <netui-data:configurePager disableDefaultPager="true"/>
+ <netui-data:header>
+ <netui-data:headerCell headerText="Product Name"/>
+ <netui-data:headerCell headerText="Detailed Product Information"/>
+ </netui-data:header>
+ <netui-data:rows>
+ <netui-data:spanCell value="${container.item}"/>
+ <netui-data:anchorCell action="productDetails" value="click for details...">
+ <netui:parameter name="key" value="${container.item}"/>
+ </netui-data:anchorCell>
+ </netui-data:rows>
+
+ </netui-data:dataGrid>
+
+
+ </netui:body>
+
+</netui:html>
Propchange: beehive/trunk/samples/system-controls-jdbc/web/demo.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/web/details.jsp
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/web/details.jsp?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/web/details.jsp (added)
+++ beehive/trunk/samples/system-controls-jdbc/web/details.jsp Tue Dec 20 11:39:41 2005
@@ -0,0 +1,62 @@
+<%@ 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>JdbcControl Sample Application</title>
+ <netui:base/>
+ <style>
+.datagrid-header{
+ background-color: #eeeeee;
+}
+.datagrid-header-cel{
+ background-color: #f0f0f0;
+}
+.custom-datagrid-header-cell{
+ background-color: #0f0f0f;
+}
+.datagrid-data-cell{
+}
+.datagrid-even{
+ background-color: #ffffff;
+}
+.datagrid-even a {
+ text-decoration: none;
+ color: #000000;
+}
+.datagrid-odd{
+ background-color: #ffffde;
+}
+.datagrid-odd a {
+ text-decoration: none;
+ color: #000000;
+}
+ </style>
+ </head>
+
+ <netui:body>
+ <p></p>
+ <p>This page displays additional data for the specified product name. Data is retrieved from the database
+ by the JdbcControl SimpleDBControl.jcx using its getProductDetails() method.</p>
+ <p></p>
+
+ <netui-data:dataGrid dataSource="pageInput.details" name="productDetailsGrid">
+ <netui-data:configurePager disableDefaultPager="true"/>
+ <netui-data:header>
+ <netui-data:headerCell headerText="Product Name"/>
+ <netui-data:headerCell headerText="Product Description"/>
+ <netui-data:headerCell headerText="Quantity"/>
+ </netui-data:header>
+ <netui-data:rows>
+ <netui-data:spanCell value="${container.item.name}"/>
+ <netui-data:spanCell value="${container.item.description}"/>
+ <netui-data:spanCell value="${container.item.quantity}"/>
+ </netui-data:rows>
+ </netui-data:dataGrid>
+ <br>
+ <p><netui:anchor action="startDemo">back</netui:anchor></p>
+ </netui:body>
+
+</netui:html>
Propchange: beehive/trunk/samples/system-controls-jdbc/web/details.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/web/index.jsp
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/web/index.jsp?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/web/index.jsp (added)
+++ beehive/trunk/samples/system-controls-jdbc/web/index.jsp Tue Dec 20 11:39:41 2005
@@ -0,0 +1,16 @@
+<%@ 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>Sample JdbcControl Page</title>
+ <netui:base/>
+ </head>
+ <netui:body>
+ <p>
+ Sample JdbcControl Page
+ <netui:anchor action="startDemo">Start Demo</netui:anchor>
+ </p>
+ </netui:body>
+</netui:html>
Propchange: beehive/trunk/samples/system-controls-jdbc/web/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: beehive/trunk/samples/system-controls-jdbc/web/sql.jsp
URL: http://svn.apache.org/viewcvs/beehive/trunk/samples/system-controls-jdbc/web/sql.jsp?rev=358081&view=auto
==============================================================================
--- beehive/trunk/samples/system-controls-jdbc/web/sql.jsp (added)
+++ beehive/trunk/samples/system-controls-jdbc/web/sql.jsp Tue Dec 20 11:39:41 2005
@@ -0,0 +1,59 @@
+<%@ 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"%>
+<%@ page import="java.sql.*,javax.naming.*,javax.sql.*" %>
+<html>
+ <head>
+ <title>SQL on Tomcat Test</title>
+ </head>
+ <body>
+ <p>
+ <b>SQL on Tomcat Test</b>
+
+<%
+ Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
+
+ Context ctx = new InitialContext();
+ if(ctx == null)
+ throw new RuntimeException("Could not create an InitialContext");
+
+ DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/JdbcControlSampleDB");
+ if(ds == null)
+ throw new RuntimeException("Could not create a DataSource");
+ out.write("<br/>found ds: " + ds + "<br/>");
+
+ Connection conn = ds.getConnection();
+ if(conn == null)
+ throw new RuntimeException("Could not get database connection");
+ out.write("got here</br>");
+
+ java.sql.Statement stmt = conn.createStatement();
+ try {
+ stmt.execute("drop table CATEGORIES");
+ stmt.close();
+ } catch(Exception ignore) {ignore.printStackTrace(); stmt.close();}
+ stmt = conn.createStatement();
+ boolean result = stmt.execute(
+ "CREATE TABLE Categories (CategoryID int GENERATED ALWAYS AS IDENTITY, CategoryName varchar (15) NOT NULL, Description CLOB (2K), CONSTRAINT PK_Categories PRIMARY KEY(CategoryID))");
+ out.write("result: " + result);
+ stmt.close();
+
+ stmt = conn.createStatement();
+ stmt.execute("insert into categories (CategoryName,Description) VALUES('Beverages','Soft drinks, coffees, teas, beers, and ales')");
+ stmt.close();
+
+ stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery("select * from categories");
+ pageContext.setAttribute("rs", rs);
+ while(rs.next()) {
+ out.write("name: " + rs.getObject("categoryname") + "<br/>");
+ out.write("name: " + rs.getObject("description") + "<br/>");
+ }
+ rs.close();
+ stmt.close();
+ conn.close();
+%>
+ </p>
+ </body>
+</html>
Propchange: beehive/trunk/samples/system-controls-jdbc/web/sql.jsp
------------------------------------------------------------------------------
svn:eol-style = native