haul 2003/01/17 03:22:37 Added: src/webapp/samples block-samples.xml src/blocks/portal-fw/conf portal-fw.xsamples src/blocks/databases/samples samples.xml sitemap.xmap src/blocks/databases/samples/xsp esql.xsd esql.xsp sitemap.xmap src/blocks/databases/samples/transform sitemap.xmap sql-page.xml sql-page.xml.sql src/blocks/databases/samples/org-db add-department.xsp add-employee.xsp employee.xml employee.xsp process-department.xsp process-employee.xsp sitemap.xmap src/blocks/databases/samples/mod-db database.xml edit-groups.xsp schema.sql sitemap.xmap stupid.xsl user-list.xsp src/blocks/databases/conf databases.xsamples src/blocks/authentication-fw/conf authentication-fw.xsamples Log: Move database samples to block Modify build system to merge *.xsample files to block-samples.xml Move authentication-fw samples to block-samples.xml Move portal-fw samples to block-samples.xml Fix simple-samples2html.xsl - only one group works - include groups and notes in balancing - make gif rooted path Revision Changes Path 1.1 xml-cocoon2/src/webapp/samples/block-samples.xml Index: block-samples.xml =================================================================== <?xml version="1.0" encoding="iso-8859-1"?> <!-- CVS: $Id: block-samples.xml,v 1.1 2003/01/17 11:22:36 haul Exp $ --> <samples xmlns:xlink="http://www.w3.org/1999/xlink" name="blocks"> </samples> 1.1 xml-cocoon2/src/blocks/portal-fw/conf/portal-fw.xsamples Index: portal-fw.xsamples =================================================================== <?xml version="1.0"?> <xsamples xpath="/samples" unless="group[@name='portal-fw']"> <group name="portal-fw"> <sample name="Portal Framework" href="portal-fw/sunspotdemoportal"> This is a demo of the portal framework integrated into Cocoon. </sample> </group> </xsamples> 1.1 xml-cocoon2/src/blocks/databases/samples/samples.xml Index: samples.xml =================================================================== <?xml version="1.0" encoding="iso-8859-1"?> <!-- CVS: $Id: samples.xml,v 1.1 2003/01/17 11:22:36 haul Exp $ --> <samples xmlns:xlink="http://www.w3.org/1999/xlink" name="database block"> <group name="SQL Transformer"> <sample name="Documentation" href="/cocoon/documentation/userdocs/transformers/sql-transformer.html"> Documentation for this component. </sample> <sample name="SQL Transformator" href="transform/sql-page" xlink:role="dynamic"> Simple example using the SQL transformer. </sample> </group> <group name="XSP"> <sample name="Documentation" href="/cocoon/documentation/userdocs/xsp/esql.html"> Documentation for this component. </sample> <sample name="ESQL Logicsheet" href="xsp/esql" xlink:role="dynamic"> Simple example of embedding SQL in a serverpage using the ESQL logicsheet. </sample> </group> <group name="Modular Database Actions"> <sample name="Documentation" href="/cocoon/documentation/userdocs/actions/database-actions.html"> Documentation for this component. </sample> <sample name="Manage Users and Groups" href="mod-db/user-list"> An example web-application built around database actions from the modular package which supports auto increments and more. </sample> </group> <group name="Original Database Actions"> <sample name="Documentation" href="/cocoon/documentation/userdocs/actions/database-actions.html"> Documentation for this component. </sample> <sample name="Manage Employees" href="org-db/employee" xlink:role="dynamic"> Adds, updates and deletes Employees to the employees table. </sample> <sample name="Insert Department" href="org-db/add-department" xlink:role="dynamic"> Adds new Departments to the department table. </sample> <sample name="Insert Employees" href="org-db/add-employee" xlink:role="dynamic"> Adds new Employees to the employees table. </sample> </group> </samples> 1.1 xml-cocoon2/src/blocks/databases/samples/sitemap.xmap Index: sitemap.xmap =================================================================== <?xml version="1.0" encoding="UTF-8"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <!-- ========================= Components ================================ --> <map:components> <map:generators default="file"/> <map:transformers default="xslt"/> <map:readers default="resource"/> <map:serializers default="html"/> <map:matchers default="wildcard"/> <map:selectors default="browser"/> </map:components> <!-- =========================== Views =================================== --> <map:views> <map:view name="content" from-label="content"> <map:serialize type="xml"/> </map:view> <map:view name="pretty-content" from-label="data"> <map:transform src="context://samples/common/style/xsl/html/simple-xml2html.xsl"/> <map:serialize type="html"/> </map:view> <map:view name="links" from-position="last"> <map:serialize type="links"/> </map:view> </map:views> <!-- =========================== Pipelines ================================= --> <map:pipelines> <map:pipeline> <map:match pattern=""> <map:redirect-to uri="samples"/> </map:match> <map:match pattern="samples"> <map:generate src="samples.xml"/> <map:transform type="xalan" src="context://samples/common/style/xsl/html/simple-samples2html.xsl"/> <map:serialize/> </map:match> <!-- samples automount --> <map:match pattern="*/**"> <map:mount uri-prefix="{1}" src="{1}/" check-reload="yes"/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> <!-- end of file --> 1.1 xml-cocoon2/src/blocks/databases/samples/xsp/esql.xsd Index: esql.xsd =================================================================== <?xml version="1.0"?> <!DOCTYPE schema SYSTEM "../../../../xdocs/dtd/XMLSchema.dtd"> <schema xmlns="http://www.w3.org/2000/10/XMLSchema" xmlns:esql="http://apache.org/cocoon/SQL/v2" > <element name="esql:connection"> <annotation> <documentation>Opens a new database connection.</documentation> </annotation> <complexType> <sequence> <choice> <sequence> <!-- not schema strings - xsp strings --> <element name="esql:driver" type="string"> <annotation> <documentation>The name of the driver to use</documentation> </annotation> </element> <element name="esql:dburl" type="string"> <annotation> <documentation>The URL of the database</documentation> </annotation> </element> <element name="esql:username" type="string" minOccurs="0" maxOccurs="1"> <annotation> <documentation>The database user's name</documentation> </annotation> </element> <element name="esql:password" type="string" minOccurs="0" maxOccurs="1"> <annotation> <documentation>The database user's password</documentation> </annotation> </element> </sequence> <element name="esql:pool" type="string"> <annotation> <documentation>The name of the database pool</documentation> </annotation> </element> </choice> <sequence> <element name="esql:execute-query" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Executes a query on the database</documentation> </annotation> <complexType> <sequence> <element name="esql:query"> <annotation> <documentation>The query to execute</documentation> </annotation> <complexType mixed="true"> <sequence> <element name="esql:parameter" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>A parameter for a prepared statement</documentation> </annotation> </element> </sequence> </complexType> </element> <element name="esql:results" minOccurs="0" maxOccurs="1"> <annotation> <documentation>This element's children are instantiated in the result tree when the query returns a resultset</documentation> </annotation> <complexType mixed="true"> <sequence> <element name="esql:row-results" minOccurs="0" maxOccurs="1"> <annotation> <documentation>This element's children are instantiated in the result tree for each row in the resultset</documentation> </annotation> <complexType mixed="true"> <sequence> <choice> <any namespace="##other" minOccurs="0" maxOccurs="unbounded" processContents="lax"/> <element name="esql:get-columns" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns a sequence of elements whose names are the current row's column names, and whose values are the current row's column values</documentation> </annotation> <element name="esql:encoding" minOccurs="0" maxOccurs="1"> <annotation> <documentation>The encoding used for this column, specified as a Java encoding name.</documentation> </annotation> </element> </element> <element name="esql:get-string" minOccurs="0" maxOccurs="unbounded" type="EsqlColumnFunction"> <annotation> <documentation>Returns the value of the given column in the current row as a string</documentation> </annotation> <element name="esql:encoding" minOccurs="0" maxOccurs="1"> <annotation> <documentation>The encoding used for this column, specified as a Java encoding name.</documentation> </annotation> </element> </element> <element name="esql:get-date" minOccurs="0" maxOccurs="unbounded" type="EsqlFormattedColumnFunction"> <annotation> <documentation>Returns the value of the given column in the current row as a date</documentation> </annotation> </element> <element name="esql:get-time" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the value of the given column in the current row as a time</documentation> </annotation> </element> <element name="esql:get-timestamp" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the value of the given column in the current row as a timestamp</documentation> </annotation> </element> <element name="esql:get-boolean" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the value of the given column in the current row as a boolean</documentation> </annotation> </element> <element name="esql:get-double" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the value of the given column in the current row as a double</documentation> </annotation> </element> <element name="esql:get-float" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the value of the given column in the current row as a float</documentation> </annotation> </element> <element name="esql:get-int" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the value of the given column in the current row as a int</documentation> </annotation> </element> <element name="esql:get-long" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the value of the given column in the current row as a long</documentation> </annotation> </element> <element name="esql:get-short" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the value of the given column in the current row as a short</documentation> </annotation> </element> <element name="esql:get-xml" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Parses the value of the given column in the current row as XML and returns it</documentation> </annotation> </element> <element name="esql:get-row-position" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the position of the current row in the resultset</documentation> </annotation> </element> <element name="esql:get-column-name" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the name of the given column in the current row</documentation> </annotation> </element> <element name="esql:get-column-label" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the label of the given column in the current row</documentation> </annotation> </element> <element name="esql:get-column-type-name" minOccurs="0" maxOccurs="unbounded"> <annotation> <documentation>Returns the type name of the given column in the current row</documentation> </annotation> </element> </choice> </sequence> </complexType> </element> <element name="esql:no-results" minOccurs="0" maxOccurs="1"> <annotation> <documentation>This element's children are instantiated in the result tree for each row in the resultset</documentation> </annotation> </element> </sequence> </complexType> </element> <element name="esql:update-results" minOccurs="0" maxOccurs="1"> <annotation> <documentation>This element's children are instantiated in the result tree if the query returns a number of rows</documentation> </annotation> </element> <element name="esql:error-results" minOccurs="0" maxOccurs="1"> <annotation> <documentation>This element's children are instantiated in the result tree if the query results in a database error. If this element does not exist, the error is passed on to the xsp layer. If it does exist, the error is caught here unless passed on explicitly.</documentation> </annotation> </element> </sequence> </complexType> </element> </sequence> </sequence> </complexType> </element> <complexType name="EsqlColumnFunction"> <annotation> <documentation>The given column is indicated by the column attribute. If the attribute's value is an integer, it is treated as the index of the column in the row, otherwise it's value is treated as the name of the column.</documentation> </annotation> <attribute name="column" type="string"/> </complexType> <complexType name="EsqlFormattedColumnFunction"> <annotation> <documentation>The value of the format attribute can used by some column value functions (e.g. date, real) as a template for formatting the column value. This is necessarily implementation dependent.</documentation> </annotation> <complexContent> <extension base="EsqlColumnFunction"> <attribute name="format" type="string"/> </extension> </complexContent> </complexType> </schema> 1.1 xml-cocoon2/src/blocks/databases/samples/xsp/esql.xsp Index: esql.xsp =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <!-- CVS: $Id: esql.xsp,v 1.1 2003/01/17 11:22:36 haul Exp $ --> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2"> <page> <title>A Database Driven XSP Page</title> <content> <esql:connection> <esql:pool>personnel</esql:pool> <para> Below you see all guys from the departments </para> <esql:execute-query> <esql:query>select * from employee</esql:query> <esql:results> <esql:row-results> <para><esql:get-string column="name"/></para> <!-- uncomment if you want columns to become tags --> <!-- <esql:get-columns/> --> </esql:row-results> </esql:results> </esql:execute-query> <hr/> <para> Below you see just some of the guys </para> <esql:execute-query> <esql:query>select * from employee</esql:query> <esql:use-limit-clause>jdbc</esql:use-limit-clause> <esql:skip-rows>1</esql:skip-rows> <esql:max-rows>2</esql:max-rows> <esql:results> <esql:row-results> <para><esql:get-string column="name"/></para> </esql:row-results> <esql:previous-results> We skipped some. </esql:previous-results> <esql:more-results> There are some more. </esql:more-results> <para> There is a total of <esql:row-count/> employees. </para> </esql:results> </esql:execute-query> <hr/> <para> Below departments and employees are printed. Without the grouping feature, the result would look like this: </para> <esql:execute-query> <esql:query> SELECT department.name, employee.id, employee.name as empName FROM department, employee WHERE department.id = employee.department_id ORDER BY department.name </esql:query> <esql:results> <esql:row-results> <Department> <xsp:attribute name='name'><esql:get-string column='name'/></xsp:attribute> <h2><esql:get-string column='name'/></h2> <para><employee><esql:get-string column='empName'/></employee></para> </Department> </esql:row-results> </esql:results> </esql:execute-query> <hr/> <para> This uses the grouping feature in esql. </para> <esql:execute-query> <esql:query> SELECT department.name, employee.id, employee.name as empName FROM department, employee WHERE department.id = employee.department_id ORDER BY department.name </esql:query> <esql:results> <esql:row-results> <esql:group group-on='name'><!-- grouping --> <Department> <xsp:attribute name='name'><esql:get-string column='name'/></xsp:attribute> <h2><esql:get-string column='name'/></h2> <esql:member><!-- grouping --> <para><employee><esql:get-string column='empName'/></employee></para> </esql:member><!--grouping --> </Department> </esql:group><!-- grouping --> </esql:row-results> </esql:results> </esql:execute-query> </esql:connection> </content> </page> </xsp:page> 1.1 xml-cocoon2/src/blocks/databases/samples/xsp/sitemap.xmap Index: sitemap.xmap =================================================================== <?xml version="1.0" encoding="UTF-8"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <!-- ========================= Components ================================ --> <map:components> <map:generators default="file"/> <map:transformers default="xslt"/> <map:readers default="resource"/> <map:serializers default="html"/> <map:matchers default="wildcard"/> <map:selectors default="browser"/> </map:components> <!-- =========================== Pipelines ================================= --> <map:pipelines> <map:pipeline> <map:match pattern="*"> <map:generate src="{1}.xsp" type="serverpages"/> <map:transform src="context://samples/stylesheets/dynamic-page2html.xsl"> <map:parameter name="view-source" value="samples/databases/xsp/{1}.xsp"/> </map:transform> <map:serialize/> </map:match> <map:match pattern=""> <map:redirect-to uri="../"/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> <!-- end of file --> 1.1 xml-cocoon2/src/blocks/databases/samples/transform/sitemap.xmap Index: sitemap.xmap =================================================================== <?xml version="1.0" encoding="UTF-8"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <!-- ========================= Components ================================ --> <map:components> <map:generators default="file"/> <map:transformers default="xslt"/> <map:readers default="resource"/> <map:serializers default="html"/> <map:matchers default="wildcard"/> <map:selectors default="browser"/> </map:components> <!-- =========================== Pipelines ================================= --> <map:pipelines> <map:pipeline> <map:match pattern="*"> <map:generate src="{1}.xml"/> <map:transform type="sql"> <map:parameter name="use-connection" value="personnel"/> <!-- Let's have a look at the user docs: "[...] The purpose of the SQLTransformer is to query a database and translate the result to XML. [...]" --> </map:transform> <map:transform src="context://samples/stylesheets/simple-sql2html.xsl"/> <map:serialize/> </map:match> <map:match pattern=""> <map:redirect-to uri="../"/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> <!-- end of file --> 1.1 xml-cocoon2/src/blocks/databases/samples/transform/sql-page.xml Index: sql-page.xml =================================================================== <?xml version="1.0"?> <page xmlns:sql="http://apache.org/cocoon/SQL/2.0"> <title>Hello</title> <content> <para>This is my first Cocoon2 page filled with sql data!</para> <execute-query xmlns="http://apache.org/cocoon/SQL/2.0"> <query> select id,name from department </query> <execute-query> <query> select id,name from employee where department_id = <ancestor-value sql:name="id" sql:level="1"/> </query> </execute-query> </execute-query> </content> </page> 1.1 xml-cocoon2/src/blocks/databases/samples/transform/sql-page.xml.sql Index: sql-page.xml.sql =================================================================== # MySQL dump 6.4 # # Host: localhost Database: test #-------------------------------------------------------- # Server version 3.22.27 # # Table structure for table 'department' # CREATE TABLE department ( id int(11) DEFAULT '0' NOT NULL, name varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (id) ); # # Dumping data for table 'department' # INSERT INTO department VALUES (1,'Programmers'); INSERT INTO department VALUES (2,'Loungers'); # # Table structure for table 'employee' # CREATE TABLE employee ( id int(11) DEFAULT '0' NOT NULL, department_id int(11) DEFAULT '0' NOT NULL, name varchar(255) DEFAULT '' NOT NULL, PRIMARY KEY (id) ); # # Dumping data for table 'employee' # INSERT INTO employee VALUES (1,1,'Donald Ball'); INSERT INTO employee VALUES (2,1,'Stefano Mazzocchi'); INSERT INTO employee VALUES (3,2,'Pierpaolo Fumagalli'); 1.1 xml-cocoon2/src/blocks/databases/samples/org-db/add-department.xsp Index: add-department.xsp =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" > <page> <title>Add a Department</title> <content> <form action="process-department" method="POST"> <input name="process" type="hidden" value="Add"/> <para>Department Name: <input name="name" type="text"/></para> <input type="submit" value="Add"/> </form> </content> </page> </xsp:page> 1.1 xml-cocoon2/src/blocks/databases/samples/org-db/add-employee.xsp Index: add-employee.xsp =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2" > <page> <title>Add an Employee</title> <content> <form action="process-employee" method="POST"> <input name="process" type="hidden" value="Add"/> <para>Employee Name: <input name="name" type="text"/></para> <para>Department: <select name="department"> <esql:connection> <esql:pool>personnel</esql:pool> <esql:execute-query> <esql:query>select id, name from department order by name</esql:query> <esql:results> <esql:row-results> <option> <xsp:attribute name="value"><esql:get-int column="id"/></xsp:attribute> <esql:get-string column="name"/> </option> </esql:row-results> </esql:results> </esql:execute-query> </esql:connection> </select> </para> <input type="submit" value="Add"/> </form> </content> </page> </xsp:page> 1.1 xml-cocoon2/src/blocks/databases/samples/org-db/employee.xml Index: employee.xml =================================================================== <?xml version="1.0"?> <employee> <connection>personnel</connection> <table name="employee"> <keys> <key param="employee" dbcol="id" type="int" mode="manual"/> </keys> <values> <value param="name" dbcol="name" type="string"/> <value param="department" dbcol="department_id" type="int"/> </values> </table> </employee> 1.1 xml-cocoon2/src/blocks/databases/samples/org-db/employee.xsp Index: employee.xsp =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2" > <page> <xsp:logic> String empID = request.getParameter("employee"); String depID = request.getParameter("department"); String name = request.getParameter("name"); String message = (String) request.getAttribute("message"); </xsp:logic> <title>Manage Employees</title> <para style="backgroud-color:#ff0000"><xsp:expr>(message == null?"":message)</xsp:expr></para> <content> <form name="EmployeeSelection"> <select size="1" name="employee" onChange="top.location.href=window.location.pathname + '?employee=' + document.forms['EmployeeSelection'].employee.options[document.forms['EmployeeSelection'].employee.options.selectedIndex].value"> <option value="-1">-- New employee --</option> <esql:connection> <esql:pool>personnel</esql:pool> <esql:execute-query> <esql:query>select id, department_id, name from employee order by name</esql:query> <esql:results> <esql:row-results> <xsp:logic> if (<esql:get-string column="id"/>.equals(empID)) { depID = <esql:get-string column="department_id"/>; name = <esql:get-string column="name"/>; xspAttr.addAttribute("", "selected", "selected", "CDATA", ""); } </xsp:logic> <option> <xsp:attribute name="value"><esql:get-int column="id"/></xsp:attribute> <esql:get-string column="name"/> </option> </esql:row-results> </esql:results> </esql:execute-query> </esql:connection> </select> </form> <form action="" method="POST" name="EmployeeEntry"> <script>document.forms["EmployeeEntry"].action = window.location.pathname</script> <input type="hidden" name="employee"> <xsp:attribute name="value"><xsp:expr>((empID != null) ? empID : "")</xsp:expr></xsp:attribute> </input> <para>Employee Name: <input name="name" type="text"> <xsp:attribute name="value"><xsp:expr>((name != null) ? name : "")</xsp:expr></xsp:attribute> </input> </para> <para>Department: <select name="department"> <option value="-1">-- Select department --</option> <esql:connection> <esql:pool>personnel</esql:pool> <esql:execute-query> <esql:query>select id, name from department order by name</esql:query> <esql:results> <esql:row-results> <xsp:logic> if (<esql:get-string column="id"/>.equals(depID)) { xspAttr.addAttribute("", "selected", "selected", "CDATA", ""); } </xsp:logic> <option> <xsp:attribute name="value"><esql:get-int column="id"/></xsp:attribute> <esql:get-string column="name"/> </option> </esql:row-results> </esql:results> </esql:execute-query> </esql:connection> </select> </para> <xsp:logic> <![CDATA[ if (empID != null && !empID.equals("-1")) { ]]> <input type="submit" name="cocoon-action-Update" value="click here to update"/> <input type="submit" name="cocoon-action-Delete" value="click here to delete"/> } else { <input type="submit" name="cocoon-action-Add" value="click here to add"/> } </xsp:logic> </form> </content> </page> </xsp:page> 1.1 xml-cocoon2/src/blocks/databases/samples/org-db/process-department.xsp Index: process-department.xsp =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2" xmlns:xsp-request="http://apache.org/xsp/request/2.0" > <xsp:logic> String process = null; String name = null; int currId = -1; </xsp:logic> <page> <xsp:logic> process = <xsp-request:get-parameter name="process"/>; name = <xsp-request:get-parameter name="name"/>; </xsp:logic> <title><xsp:expr>process</xsp:expr> Department Processed</title> <content> <esql:connection> <esql:pool>personnel</esql:pool> <esql:execute-query> <esql:query> select max(id) as maxid from department </esql:query> <esql:results> <esql:row-results> <xsp:logic> currId = <esql:get-int column="maxid"/>; </xsp:logic> <esql:execute-query> <esql:query> insert into department (id, name) values ( (<esql:parameter><xsp:expr>currId</xsp:expr></esql:parameter> + 1), <esql:parameter><xsp:expr>name</xsp:expr></esql:parameter> ) </esql:query> </esql:execute-query> </esql:row-results> </esql:results> </esql:execute-query> </esql:connection> <para><xsp:expr>name</xsp:expr> added</para> <a href="../welcome">Back to the welcome page</a> </content> </page> </xsp:page> 1.1 xml-cocoon2/src/blocks/databases/samples/org-db/process-employee.xsp Index: process-employee.xsp =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2" xmlns:xsp-request="http://apache.org/xsp/request/2.0" > <xsp:logic> String process = null; String name = null; String departmentId = null; int currId = -1; </xsp:logic> <page> <xsp:logic> process = <xsp-request:get-parameter name="process"/>; name = <xsp-request:get-parameter name="name"/>; departmentId = <xsp-request:get-parameter name="department"/>; </xsp:logic> <title><xsp:expr>process</xsp:expr> Employee Processed</title> <content> <esql:connection> <esql:pool>personnel</esql:pool> <esql:autocommit>false</esql:autocommit> <esql:execute-query> <esql:query>select max(id) as maxid from employee</esql:query> <esql:results> <esql:row-results> <xsp:logic> currId = <esql:get-int column="maxid"/>; </xsp:logic> <esql:execute-query> <esql:query> insert into employee (id, name, department_id) values ( (<esql:parameter><xsp:expr>currId + 1</xsp:expr></esql:parameter>), <esql:parameter><xsp:expr>name</xsp:expr></esql:parameter>, <esql:parameter><xsp:expr>departmentId</xsp:expr></esql:parameter> ) </esql:query> </esql:execute-query> </esql:row-results> </esql:results> </esql:execute-query> </esql:connection> <para><xsp:expr>name</xsp:expr> added</para> <a href="../welcome">Back to the welcome page</a> </content> </page> </xsp:page> 1.1 xml-cocoon2/src/blocks/databases/samples/org-db/sitemap.xmap Index: sitemap.xmap =================================================================== <?xml version="1.0" encoding="UTF-8"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <!-- ========================= Components ================================ --> <map:components> <map:generators default="file"/> <map:transformers default="xslt"/> <map:readers default="resource"/> <map:serializers default="html"/> <map:matchers default="wildcard"/> <map:selectors default="browser"/> <!-- original database actions --> <map:actions> <map:action logger="sitemap.action.add-employee" name="add-employee" src="org.apache.cocoon.acting.DatabaseAddAction"/> <map:action logger="sitemap.action.del-employee" name="del-employee" src="org.apache.cocoon.acting.DatabaseDeleteAction"/> <map:action logger="sitemap.action.upd-employee" name="upd-employee" src="org.apache.cocoon.acting.DatabaseUpdateAction"/> </map:actions> </map:components> <!-- ========================== Action sets ================================ --> <!-- Action sets group actions together. If some actions are often used together in pipeline fragments, it's easier to group them and refer to the group. For more info, please see the docs. --> <map:action-sets> <map:action-set name="employee"> <map:act action="Add" type="add-employee"/> <map:act action="Delete" type="del-employee"/> <map:act action="Update" type="upd-employee"/> </map:action-set> </map:action-sets> <!-- =========================== Pipelines ================================= --> <map:pipelines> <map:pipeline> <map:match pattern="employee"> <map:act set="employee"> <map:parameter name="descriptor" value="employee.xml"/> <!-- Here an action is used. To be precise: all actions that were grouped together to a set named "employee". See user docs on actions for more on this. This fragment until the closing tag of map:act is only included if at least one action of this set completes successfully. --> <map:generate src="employee.xsp" type="serverpages"/> <map:transform src="context://samples/stylesheets/dynamic-page2html.xsl"> <map:parameter name="view-source" value="samples/databases/org-db/employee.xsp"/> </map:transform> <map:serialize/> </map:act> </map:match> <map:match pattern="*"> <map:generate src="{1}.xsp" type="serverpages"/> <map:transform src="context://samples/stylesheets/dynamic-page2html.xsl"> <map:parameter name="view-source" value="samples/databases/org-db/{1}.xsp"/> </map:transform> <map:serialize/> </map:match> <map:match pattern=""> <map:redirect-to uri="../"/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> <!-- end of file --> 1.1 xml-cocoon2/src/blocks/databases/samples/mod-db/database.xml Index: database.xml =================================================================== <root> <connection>personnel</connection> <!-- this is only used when no connection is specified in sitemap --> <!-- a table consists of key attributes and plain values, keys are handled differently on operations. Most significantly when inserting a new row, we need to determine if a value needs to be set by the action or wheter it's an autoincrement. Next, autoincrements work differently on different DBMSs, so we need special support to find out about the value set by the DBMS. --> <table name="user" alias="user"> <!-- @name is the table's name in the DB --> <!-- @alias is used instead (if present) for those weirdos that put --> <!-- complex queries into @name ;-) You obviously loose all but select --> <!-- functionality, although this is not enforced. --> <keys> <key name="uid" type="int" autoincrement="true"> <!-- @name is the column's name --> <!-- @type is the column's jdbc type --> <!-- @autoincrement : column value is determined by special component --> <mode name="auto" type="autoincr"/> <!-- this entry says: when inserting a new column into a autoincrement column (@type="autoincr"), use the module named "auto" to find out about how to handle this column. All other operations use the default mode. There are two distinct mode types: "autoincr" for insert operations on autoincrement columns and "others" for all other (delete, update, select) operations on autoincrement columns and all operations on other columns. --> </key> </keys> <values> <value name="name" type="string"></value> <value name="firstname" type="string"></value> <value name="uname" type="string"></value> </values> </table> <table name="user_groups"> <keys> <key name="uid" type="int"> <!-- Next we have two different modes: "request" and "attrib". See below for explanation. --> <mode name="request-param" parameter="user_groups.uid" type="request"/> <mode name="request-attr" parameter="org.apache.cocoon.components.modules.output.OutputModule:user.uid[0]" type="attrib"/> <!-- note here, that the actual parameter has a row index to it. We don't expect to insert more than one user plus her groups at any time, so we append just "[0]". However, if that would be the case, we could let this column be part of a set and ask for "[*]" instead. Might be tricky to find the associated groups, though, if we insert x users plus y_1, y_2, ... , y_x groups.... --> </key> <key name="gid" type="int" set="master"> <!-- now, this is tricky: when we need to insert multiple rows, those attributes that differ in these rows are marked to belong to a "set". One column is marked to be the "master" while all others need to be "slaves". A master is used to obtain a sorted set of index values for these rows. These will then be used to get the actual values for the master and slave columns. Note that it is not necessary to have the master be a key column. Note too, that an autoincrement column may not serve as a master here. This attribute may be specified on a column level or on a mode level to allow different behavious. Mode level @set is only considered if @set is not present on column level. Plus, as deletes and selects consider only key attributes while updates consider values as well, there's no harm having a single set for these three actions. In this case the set master needs to be a key column, though. --> <!-- special mode type "all" is used for all operations --> <mode name="request-param" parameter="user_groups.gid" type="all"/> </key> </keys> </table> <table name="groups"> <keys> <key name="gid" type="int" autoincrement="true"> <mode name="auto" type="autoincr"/> </key> </keys> <values> <value name="gname" type="string"/> </values> </table> <!-- the existing DB actions try to work on all tables listed in this descriptor file. Just like some other newer actions this one also allows for table-sets. If no set is found, it defaults to the previous behaviour. Note though, that the syntax is slightly different from the "old" DB actions file. --> <table-set name="user"> <table name="user"/> </table-set> <table-set name="groups"> <table name="groups"/> </table-set> <table-set name="user+groups"> <table name="user"/> <table name="user_groups" others-mode="attrib"/> <!-- below we have another table set that inserts data into user_groups. When inserting into user_groups alone, we'd know the uid before hand, but when inserting a new user as well, we need to find out the autoincrement value first. Therefore we need a different approach to obtain that value. So we can instruct the action to use a different type (here "attrib") which reads the result from the first insert operation. --> </table-set> <table-set name="user_groups"> <table name="user_groups" others-mode="request"/> </table-set> </root> 1.1 xml-cocoon2/src/blocks/databases/samples/mod-db/edit-groups.xsp Index: edit-groups.xsp =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2" xmlns:xsp-request="http://apache.org/xsp/request/2.0" > <!-- --> <xsp:structure> <xsp:include>java.util.Enumeration</xsp:include> </xsp:structure> <page> <title>edit-groups</title> <esql:connection> <esql:pool>personnel</esql:pool> <xsp:logic> String user = <xsp-request:get-parameter name="user.uid"/>; if ( user == null ) { user = <xsp-request:get-parameter name="user_groups.uid"/>; } int uid=-1; if ( user != null ) { try { uid = Integer.parseInt(user); } catch ( NumberFormatException e ) { uid = -1; } } String uname=""; String name=""; String firstname=""; if ( uid != -1 ) { <esql:execute-query> <esql:query>select * from user where uid=<esql:parameter><xsp:expr>uid</xsp:expr></esql:parameter></esql:query> <esql:results> <esql:row-results> <xsp:logic> uid=<esql:get-int column="uid"/>; uname=<esql:get-string column="uname"/>; name=<esql:get-string column="name"/>; firstname=<esql:get-string column="firstname"/>; </xsp:logic> </esql:row-results> </esql:results> </esql:execute-query> } </xsp:logic> <h1>Edit User's Groups</h1> <table cellpadding="2" cellspacing="2" border="0"> <tbody> <form> <tr> <td valign="Top" align="Right">uname </td> <td valign="Top"> <input type="text" name="user.uname"> <xsp:attribute name="value"><xsp:expr>uname</xsp:expr></xsp:attribute> </input> </td> <td> </td> </tr> <tr> <td valign="Top" align="Right">firstname, name</td> <td> <input type="text" name="user.firstname"> <xsp:attribute name="value"><xsp:expr>firstname</xsp:expr></xsp:attribute> </input>, <input type="text" name="user.name"> <xsp:attribute name="value"><xsp:expr>name</xsp:expr></xsp:attribute> </input> </td> <td> <input type="hidden" name="user.uid"> <xsp:attribute name="value"><xsp:expr>uid</xsp:expr></xsp:attribute> </input> <input type="submit" name="upd-user" value="update"/> </td> </tr> </form> <tr> <td valign="Top"> </td> <td valign="Top" align="right"> <form> <table border="1"> <tbody> <tr> <td> <table border="0"> <tbody> <tr> <td>current groups</td> </tr> <tr> <td> <select multiple="1" name="user_groups.gid" size="7"> <esql:execute-query> <esql:query>select gid, gname from user_groups, groups where user_groups.gid = groups.gid and uid=<esql:parameter type="int"><xsp:expr>uid</xsp:expr></esql:parameter> order by gname</esql:query> <esql:results> <esql:row-results> <option> <xsp:attribute name="value"><esql:get-string column="gid"/></xsp:attribute> <esql:get-string column="gname"/> </option> </esql:row-results> </esql:results> </esql:execute-query> </select> </td> </tr> <tr> <td valign="Top"> <input type="hidden" name="user_groups.uid"> <xsp:attribute name="value"><xsp:expr>uid</xsp:expr></xsp:attribute> </input> <input type="submit" name="remove-groups" value="remove"/> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </form> </td> <td valign="Top" align="left"> <form> <table border="1"> <tbody> <tr> <td> <table border="0"> <tbody> <tr> <td>available groups</td> </tr> <tr> <td> <select name="user_groups.gid" multiple="1" size="7"> <esql:execute-query> <esql:query>select gid, gname from groups where gid not in (select gid from user_groups where uid=<esql:parameter type="int"><xsp:expr>uid</xsp:expr></esql:parameter>) order by gname</esql:query> <esql:results> <esql:row-results> <option> <xsp:attribute name="value"><esql:get-string column="gid"/></xsp:attribute> <esql:get-string column="gname"/> </option> </esql:row-results> </esql:results> </esql:execute-query> </select> </td> </tr> <tr> <td valign="Top"> <input type="hidden" name="user_groups.uid"> <xsp:attribute name="value"><xsp:expr>uid</xsp:expr></xsp:attribute> </input> <input type="submit" name="add-groups" value="add"/></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </form> </td> </tr> </tbody> </table> <div align="Right"><form action="user-list"><input value="back to list" type="submit"/></form></div> </esql:connection> <hr/> <p><h3>Request Attributes</h3></p> <p> <table border="0"> <tbody> <xsp:logic>{ Enumeration e=request.getAttributeNames(); while ( e.hasMoreElements() ) { String attribute = (String) e.nextElement(); Object value = request.getAttribute(attribute); <tr> <td align="right"><xsp:expr>attribute</xsp:expr></td> <td>="<xsp:expr>value</xsp:expr>"</td> </tr> } }</xsp:logic> </tbody> </table> </p> <hr/> <p><h3>Request Parameters</h3></p> <p> <table border="0"> <tbody> <xsp:logic>{ Enumeration e=request.getParameterNames(); while ( e.hasMoreElements() ) { String attribute = (String) e.nextElement(); Object[] value = request.getParameterValues(attribute); for (int i=0; i < value.length; i++) { <tr> <td align="right"><xsp:expr>attribute</xsp:expr>[<xsp:expr>i</xsp:expr>]</td> <td>="<xsp:expr>value[i]</xsp:expr>"</td> </tr> } } }</xsp:logic> </tbody> </table> </p> <hr/> </page> </xsp:page> 1.1 xml-cocoon2/src/blocks/databases/samples/mod-db/schema.sql Index: schema.sql =================================================================== -- this is the hsqldb schema file -- to adapt it to another RDBMS, replace column type identity -- with appropriate autoincrement type, e.g. SERIAL for informix -- you might want to add "on delete cascade" to foreign keys in -- taböe user_groups create table user ( uid integer identity primary key, name varchar(50), firstname varchar(50), uname varchar(20), unique (uname) ); create table groups ( gid integer identity primary key, gname varchar(20), unique (gname) ); create table user_groups ( uid integer, gid integer, primary key (uid,gid), foreign key (uid) references user(uid), foreign key (gid) references groups(gid) ); 1.1 xml-cocoon2/src/blocks/databases/samples/mod-db/sitemap.xmap Index: sitemap.xmap =================================================================== <?xml version="1.0"?> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <!-- ========================= Components ============================== --> <map:components> <!-- most components are inherited from parent sitemap --> <!-- just make sure that defaults suit our needs --> <map:generators default="file"/> <map:transformers default="xslt"/> <map:readers default="resource"/> <map:serializers default="html"/> <map:matchers default="wildcard"/> <map:selectors default="browser"/> <map:actions> <!-- these action are in addition to the ones inherited --> <!-- declare actions for database operations --> <map:action name="mod-db-add" src="org.apache.cocoon.acting.modular.DatabaseAddAction"> <descriptor>database.xml</descriptor> <!-- shall we throw an exception in addition to rolling back the transaction when encountering an error during database ops? --> <throw-exception>false</throw-exception> <!-- if results should be directed to another destination than the default request attributes, use e.g. <output>session</output> this can also be specified on the fly through a map:parameter named "output" remember, that input-/output-modules need to be declared in your cocoon.xconf in order to be used here. --> </map:action> <map:action name="mod-db-del" src="org.apache.cocoon.acting.modular.DatabaseDeleteAction"> <descriptor>database.xml</descriptor> <throw-exception>false</throw-exception> </map:action> <map:action name="mod-db-upd" src="org.apache.cocoon.acting.modular.DatabaseUpdateAction"> <descriptor>database.xml</descriptor> <throw-exception>false</throw-exception> </map:action> <!-- a real world application would use the form validation here --> <!-- this action just checks for existence of request parameters --> <map:action name="req-params" src="org.apache.cocoon.acting.RequestParameterExistsAction"/> </map:actions> </map:components> <!-- ======================= Views ================================= --> <map:views> <map:view name="content" from-label="content"> <map:serialize type="xml" mime-type="text/plain"/> </map:view> </map:views> <!-- ======================= Pipelines ================================= --> <map:pipelines> <map:pipeline> <!-- ========================== Modular DB ================================= --> <map:match pattern=""> <map:redirect-to uri="user-list"/> </map:match> <map:match pattern="*"> <!-- First, the logic to do all the database operations. Note, that we do no parameter validation here, just see if some parameters are present. For a real application, you'd want to check their values as well. Note too, that in a more complex setup you'd want to use an action set for this rather than spell it out everywhere. --> <!-- ______________________________ inserts ______________________________ --> <!-- add new groups to a user's groups --> <map:act type="req-params"> <map:parameter name="parameters" value="add-groups user_groups.uid user_groups.gid"/> <map:act type="mod-db-add"> <map:parameter name="table-set" value="user_groups"/> </map:act> </map:act> <!-- add onw new group --> <map:act type="req-params"> <map:parameter name="parameters" value="add-group groups.gname"/> <map:act type="mod-db-add"> <map:parameter name="table-set" value="groups"/> </map:act> </map:act> <!-- add one new user --> <!-- Actually, this one is not used anymore. The one below works well when no groups are supplied. --> <map:act type="req-params"> <map:parameter name="parameters" value="add-user user.name user.firstname user.uname"/> <map:act type="mod-db-add"> <map:parameter name="table-set" value="user"/> </map:act> </map:act> <!-- add one new user plus groups --> <map:act type="req-params"> <map:parameter name="parameters" value="add-user-groups user.name user.firstname user.uname"/> <map:act type="mod-db-add"> <map:parameter name="table-set" value="user+groups"/> </map:act> </map:act> <!-- ______________________________ updates ______________________________ --> <!-- update one user --> <map:act type="req-params"> <map:parameter name="parameters" value="upd-user user.uid user.name user.firstname user.uname"/> <map:act type="mod-db-upd"> <map:parameter name="table-set" value="user"/> </map:act> </map:act> <!-- update one group --> <map:act type="req-params"> <map:parameter name="parameters" value="upd-group groups.gid groups.gname"/> <map:act type="mod-db-upd"> <map:parameter name="table-set" value="groups"/> </map:act> </map:act> <!-- ______________________________ deletes ______________________________ --> <!-- delete one user --> <map:act type="req-params"> <map:parameter name="parameters" value="del-user user.uid"/> <map:act type="mod-db-del"> <map:parameter name="table-set" value="user"/> </map:act> </map:act> <!-- delete one group --> <map:act type="req-params"> <map:parameter name="parameters" value="del-group groups.gid"/> <map:act type="mod-db-del"> <map:parameter name="table-set" value="groups"/> </map:act> </map:act> <!-- delete groups from a user's groups --> <map:act type="req-params"> <map:parameter name="parameters" value="remove-groups user_groups.uid user_groups.gid"/> <map:act type="mod-db-del"> <map:parameter name="table-set" value="user_groups"/> </map:act> </map:act> <!-- ______________________________ content ______________________________ --> <map:generate type="serverpages" src="{1}.xsp"/> <map:transform src="context://samples/stylesheets/dynamic-page2html.xsl"> <map:parameter name="view-source" value="samples/databases/mod-db/{1}.xsp"/> </map:transform> <map:transform src="stupid.xsl"/> <map:serialize/> </map:match> </map:pipeline> </map:pipelines> </map:sitemap> 1.1 xml-cocoon2/src/blocks/databases/samples/mod-db/stupid.xsl Index: stupid.xsl =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:variable name="tablecolor">#d0f0d0</xsl:variable> <xsl:variable name="mediumtablecolor">#e0ffe0</xsl:variable> <xsl:variable name="lighttablecolor">#f0fff0</xsl:variable> <xsl:template match="sqltbl"> <xsl:element name="table"> <xsl:attribute name="border">1</xsl:attribute> <xsl:attribute name="align">center</xsl:attribute> <xsl:attribute name="bgcolor"><xsl:value-of select="$tablecolor"/></xsl:attribute> <xsl:element name="tr"> <xsl:apply-templates select="child::*[1]" mode="head"/> </xsl:element> <xsl:for-each select="child::*"> <xsl:element name="tr"> <xsl:apply-templates select="."/> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template> <xsl:template match="sqltblrow" mode="head"> <xsl:for-each select="./child::*"> <xsl:element name="th"> <xsl:value-of select="name()"/> </xsl:element> </xsl:for-each> </xsl:template> <xsl:template match="sqltblrow"> <xsl:for-each select="./child::*"> <xsl:element name="td"> <xsl:attribute name="valign">top</xsl:attribute> <xsl:apply-templates/> </xsl:element> </xsl:for-each> </xsl:template> <xsl:template match="sql-set"> <xsl:element name="table"> <xsl:attribute name="border">1</xsl:attribute> <xsl:attribute name="bgcolor"><xsl:value-of select="$mediumtablecolor"/></xsl:attribute> <xsl:for-each select="./child::*"> <xsl:element name="tr"> <xsl:element name="td"> <xsl:apply-templates/> </xsl:element> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template> <xsl:template name="sql-set-item"> <xsl:value-of select="."/> <xsl:apply-templates/> </xsl:template> <xsl:template match="sql-list"> <xsl:element name="table"> <xsl:attribute name="border">1</xsl:attribute> <xsl:attribute name="bgcolor"><xsl:value-of select="$mediumtablecolor"/></xsl:attribute> <xsl:variable name="i"><xsl:value-of select="position()"/></xsl:variable> <xsl:for-each select="./child::*"> <xsl:element name="tr"> <xsl:element name="td"> <xsl:attribute name="bgcolor"><xsl:value-of select="$lighttablecolor"/></xsl:attribute> <xsl:value-of select="@pos"/>. </xsl:element> <xsl:element name="td"> <xsl:apply-templates/> </xsl:element> </xsl:element> </xsl:for-each> </xsl:element> </xsl:template> <xsl:template name="sql-list-item"> <xsl:value-of select="."/> <xsl:apply-templates/> </xsl:template> <xsl:template match="sql-row"> <xsl:element name="table"> <xsl:attribute name="border">1</xsl:attribute> <xsl:attribute name="bgcolor"><xsl:value-of select="$mediumtablecolor"/></xsl:attribute> <xsl:element name="tr"> <xsl:for-each select="./child::*"> <xsl:element name="td"> <xsl:apply-templates/> </xsl:element> </xsl:for-each> </xsl:element> </xsl:element> </xsl:template> <xsl:template name="sql-row-item"> <xsl:value-of select="."/> <xsl:apply-templates/> </xsl:template> <xsl:template match="@*|node()" priority="-1"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*|node()" priority="-1" mode="head"> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="head"/> </xsl:copy> </xsl:template> <xsl:template match="error"> <xsl:element name="table"> <xsl:attribute name="align">center</xsl:attribute> <xsl:attribute name="width">100%</xsl:attribute> <xsl:attribute name="bgcolor">#ffe0e0</xsl:attribute> <xsl:element name="tr"> <xsl:element name="td"> <xsl:attribute name="align">center</xsl:attribute> <xsl:element name="big"> <xsl:apply-templates/> </xsl:element> </xsl:element> </xsl:element> </xsl:element> </xsl:template> </xsl:stylesheet> 1.1 xml-cocoon2/src/blocks/databases/samples/mod-db/user-list.xsp Index: user-list.xsp =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:esql="http://apache.org/cocoon/SQL/v2" xmlns:xsp-request="http://apache.org/xsp/request/2.0" > <xsp:structure> <xsp:include>java.util.Enumeration</xsp:include> </xsp:structure> <page> <title>user-list</title> <content> <h1>Modular Database Actions</h1> <hr/> <p>The intention is to factor out those parts that are dependent on the utilised DBMS as well as the methods used to obtain the values and communicate results. Therefore three classes of modules exist:</p> <ol> <li>Input Modules read data from some source (e.g. the request object or session attributes or whatever)</li> <li>Output Modules send the data to an arbitrary destination. Again, this could be request attributes or anything else. When the database transaction finishes, it is signalled to them whether the transaction succeeded or failed.</li> <li>Database Modules determine the value of a key attribute column in a database if it's is of auto increment type. This could be by querying the database, reading from an arbitrary source (e.g. request object) or just skipping the column when inserting a row and querying the database afterwards. This needs to be done e.g. for Informix's SERIAL or HSQLDB's IDENTITY column types.</li> </ol> <hr/> <h2>Current database content</h2> <esql:connection> <esql:pool>personnel</esql:pool> <p> <sqltbl> <esql:execute-query> <esql:query>select * from user order by name, firstname, uname, uid</esql:query> <esql:results> <esql:row-results> <sqltblrow> <name> <esql:get-string column="name"/> </name> <firstname> <esql:get-string column="firstname"/> </firstname> <uname> <esql:get-string column="uname"/> </uname> <action> <form action="edit-groups"> <input type="hidden" name="user.uid"> <xsp:attribute name="value"><esql:get-string column="uid"/></xsp:attribute> </input> <input type="submit" name="edit-user" value="edit"/> </form> <form> <input type="hidden" name="user.uid"> <xsp:attribute name="value"><esql:get-string column="uid"/></xsp:attribute> </input> <input type="submit" name="del-user" value="delete"/> </form> </action> </sqltblrow> </esql:row-results> </esql:results> <esql:error-results> <error><esql:get-message/></error> </esql:error-results> </esql:execute-query> <form method="Get"> <sqltblrow> <name> <input type="text" name="user.name" size="20" maxsize="20"> <xsp:attribute name="value"><!-- <xsp-request:get-parameter default="" name="user.name"/> --></xsp:attribute> </input> </name> <firstname> <input type="text" name="user.firstname" size="20" maxsize="20"> <xsp:attribute name="value"><!-- <xsp-request:get-parameter default="" name="user.firstname"/> --></xsp:attribute> </input> </firstname> <uname> <input type="text" name="user.uname" size="20" maxsize="20"> <xsp:attribute name="value"><!-- <xsp-request:get-parameter default="" name="user.uname"/> --></xsp:attribute> </input> </uname> <action> <select multiple="1" name="user_groups.gid" size="4"> <esql:execute-query> <esql:query>select gid, gname from groups order by gname</esql:query> <esql:results> <esql:row-results> <option> <xsp:attribute name="value"><esql:get-string column="gid"/></xsp:attribute> <esql:get-string column="gname"/> </option> </esql:row-results> </esql:results> </esql:execute-query> </select> <input type="submit" name="add-user-groups" value="new user"/> </action> </sqltblrow> </form> </sqltbl> </p> <p> <sqltbl> <esql:execute-query> <esql:query>select * from groups order by gname</esql:query> <esql:results> <esql:row-results> <form> <sqltblrow> <gname> <input type="text" name="groups.gname"> <xsp:attribute name="value"><esql:get-string column="gname"/></xsp:attribute> </input> <input type="hidden" name="groups.gid"> <xsp:attribute name="value"><esql:get-string column="gid"/></xsp:attribute> </input> <input type="submit" name="upd-group" value="update"/> <input type="submit" name="del-group" value="delete"/> </gname> </sqltblrow> </form> </esql:row-results> </esql:results> <esql:error-results> <error><esql:get-message/></error> </esql:error-results> </esql:execute-query> <sqltblrow> <gname> <form> <input type="text" name="groups.gname" size="20" maxsize="20"> <xsp:attribute name="value"><!-- <xsp-request:get-parameter default="" name="groups.gname"/> --></xsp:attribute> </input> <input type="submit" name="add-group" value="new group"/> </form> </gname> </sqltblrow> </sqltbl> </p> <p> <form> <esql:execute-query> <esql:query>select user.uid, user.uname, groups.gid, groups.gname from user, user_groups, groups where user.uid=user_groups.uid and user_groups.gid=groups.gid order by user.uname, groups.gname</esql:query> <esql:results> <sqltbl> <esql:row-results> <form action="edit-groups"> <sqltblrow> <uname> <input type="hidden" name="user.uid"> <xsp:attribute name="value"><esql:get-string column="uid"/></xsp:attribute> </input> <esql:get-string column="uname"/> </uname> <gname><esql:get-string column="gname"/></gname> <action> <input value="edit groups" type="submit"/> </action> </sqltblrow> </form> </esql:row-results> </sqltbl> </esql:results> <esql:error-results> <error><esql:get-message/></error> </esql:error-results> </esql:execute-query> </form> </p> </esql:connection> <hr/> <p><h2>Status Information</h2></p> <p><h3>Request Attributes</h3></p> <p> <table border="0"> <tbody> <xsp:logic>{ Enumeration e=request.getAttributeNames(); while ( e.hasMoreElements() ) { String attribute = (String) e.nextElement(); Object value = request.getAttribute(attribute); <tr> <td align="right"><xsp:expr>attribute</xsp:expr></td> <td>="<xsp:expr>value</xsp:expr>"</td> </tr> } }</xsp:logic> </tbody> </table> </p> <p><h3>Request Parameters</h3></p> <p> <table border="0"> <tbody> <xsp:logic>{ Enumeration e=request.getParameterNames(); while ( e.hasMoreElements() ) { String attribute = (String) e.nextElement(); Object[] value = request.getParameterValues(attribute); for (int i=0; i < value.length; i++) { <tr> <td align="right"><xsp:expr>attribute</xsp:expr>[<xsp:expr>i</xsp:expr>]</td> <td>="<xsp:expr>value[i]</xsp:expr>"</td> </tr> } } }</xsp:logic> </tbody> </table><br/> </p> <hr/> </content> </page> </xsp:page> 1.1 xml-cocoon2/src/blocks/databases/conf/databases.xsamples Index: databases.xsamples =================================================================== <?xml version="1.0"?> <xsamples xpath="/samples" unless="group[@name='databases']"> <group name="databases"> <note> For the examples of this block to work, either the HSQLDB block needs to be present as well or another RDBMS backend needs to be configured. Schema information is contained in each subdirectory of samples/databases. </note> <sample name="Samples" href="databases/samples"> Continue to database block samples. </sample> </group> </xsamples> 1.1 xml-cocoon2/src/blocks/authentication-fw/conf/authentication-fw.xsamples Index: authentication-fw.xsamples =================================================================== <?xml version="1.0"?> <xsamples xpath="/samples" unless="group[@name='authentication-fw']"> <group name="authentication-fw"> <sample name="Authentication Framework" href="authentication-fw/login"> This is a demo of the authentication framework integrated into Cocoon. </sample> </group> </xsamples>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]