You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by st...@apache.org on 2004/03/11 17:59:51 UTC
cvs commit: cocoon-2.1/src/blocks/ojb/samples/woody employee.js employee.xml employee_bind.xml employee_template.xml success.xsp
stephan 2004/03/11 08:59:51
Modified: src/blocks/ojb/conf ojb.xsamples
src/blocks/ojb/samples sitemap.xmap welcome.xml
Added: src/blocks/ojb/samples/forms employee.js employee.xml
employee_bind.xml employee_template.xml success.xsp
Removed: src/blocks/ojb/samples/woody employee.js employee.xml
employee_bind.xml employee_template.xml success.xsp
Log:
Update ojb block to cforms, but seems not to work:
PersistenceBrokerException: Cannot get Connection from DataSource named null
Revision Changes Path
1.4 +4 -0 cocoon-2.1/src/blocks/ojb/conf/ojb.xsamples
Index: ojb.xsamples
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/ojb/conf/ojb.xsamples,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ojb.xsamples 6 Mar 2004 02:25:38 -0000 1.3
+++ ojb.xsamples 11 Mar 2004 16:59:50 -0000 1.4
@@ -18,6 +18,10 @@
<xsamples xpath="/samples" unless="group[@name='OJB']">
<group name="OJB">
+ <note>
+ For the examples of this block to work, you need to download
+ the Java Data Objects (JDO) Reference Implementation from java.sun.com .
+ </note>
<sample name="OJB" href="ojb/">
Apache Object/Relational Bridge.
</sample>
1.7 +24 -28 cocoon-2.1/src/blocks/ojb/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/ojb/samples/sitemap.xmap,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- sitemap.xmap 6 Mar 2004 02:26:13 -0000 1.6
+++ sitemap.xmap 11 Mar 2004 16:59:50 -0000 1.7
@@ -19,19 +19,15 @@
<map:components>
- <map:transformers default="xalan">
- <map:transformer name="woody" src="org.apache.cocoon.woody.transformation.WoodyTemplateTransformer" logger="woody"/>
- <map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
- <catalogues default="other">
- <catalogue id="other" name="OtherMessages" location="context://samples/woody/messages"/>
- <catalogue id="woody" name="WoodyMessages" location="context://samples/woody/messages"/>
- </catalogues>
- <cache-at-startup>true</cache-at-startup>
- </map:transformer>
- </map:transformers>
-
- <map:pipes default="caching">
- </map:pipes>
+ <map:transformers default="xalan">
+ <map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
+ <catalogues default="forms">
+ <catalogue id="other" name="OtherMessages" location="messages"/>
+ <catalogue id="forms" name="FormMessages" location="messages"/>
+ </catalogues>
+ <cache-at-startup>true</cache-at-startup>
+ </map:transformer>
+ </map:transformers>
</map:components>
@@ -52,7 +48,7 @@
<!-- indicates what flowscript to attach to this sitemap -->
<map:flow language="javascript">
- <map:script src="woody/employee.js"/>
+ <map:script src="forms/employee.js"/>
</map:flow>
<map:pipelines>
@@ -79,48 +75,48 @@
</map:match>
<!--
- | "Form1" example, demonstrates usage of flow and woody
+ | "Form1" example, demonstrates usage of flow and forms
-->
- <map:match pattern="jdo/woody/employee">
- <map:call function="woody">
+ <map:match pattern="jdo/forms/employee">
+ <map:call function="forms">
<map:parameter name="function" value="employeeform_jdo"/>
- <map:parameter name="form-definition" value="woody/employee.xml"/>
- <map:parameter name="bindingURI" value="woody/employee_bind.xml"/>
+ <map:parameter name="form-definition" value="forms/employee.xml"/>
+ <map:parameter name="bindingURI" value="forms/employee_bind.xml"/>
</map:call>
</map:match>
- <map:match pattern="jdo/woody/employee-form-display">
- <map:generate src="woody/employee_template.xml"/>
- <map:transform type="woody"/>
+ <map:match pattern="jdo/forms/employee-form-display">
+ <map:generate src="forms/employee_template.xml"/>
+ <map:transform type="form"/>
<map:transform type="i18n">
<map:parameter name="locale" value="en-US"/>
</map:transform>
- <map:transform src="context://samples/woody/xsl/html/woody-default.xsl"/>
+ <map:transform src="context://samples/forms/xsl/html/forms-default.xsl"/>
<map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="servletPath" value="{request:servletPath}"/>
<map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
- <map:parameter name="file" value="woody/employee.xml"/>
+ <map:parameter name="file" value="forms/employee.xml"/>
<map:parameter name="remove" value="{0}"/>
</map:transform>
<map:serialize/>
</map:match>
- <map:match pattern="jdo/woody/employee-form-success">
- <map:generate type="serverpages" src="woody/success.xsp"/>
+ <map:match pattern="jdo/forms/employee-form-success">
+ <map:generate type="serverpages" src="forms/success.xsp"/>
<map:transform src="context://samples/common/style/xsl/html/simple-page2html.xsl">
<map:parameter name="contextPath" value="{request:contextPath}"/>
<map:parameter name="servletPath" value="{request:servletPath}"/>
<map:parameter name="sitemapURI" value="{request:sitemapURI}"/>
- <map:parameter name="file" value="woody/success.xsp"/>
+ <map:parameter name="file" value="forms/success.xsp"/>
<map:parameter name="remove" value="{0}"/>
</map:transform>
<map:serialize/>
</map:match>
<!-- Manages continuations -->
- <map:match pattern="jdo/woody/*.continue">
+ <map:match pattern="jdo/forms/*.continue">
<map:call continuation="{1}"/>
</map:match>
1.7 +4 -4 cocoon-2.1/src/blocks/ojb/samples/welcome.xml
Index: welcome.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/ojb/samples/welcome.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- welcome.xml 6 Mar 2004 02:26:13 -0000 1.6
+++ welcome.xml 11 Mar 2004 16:59:50 -0000 1.7
@@ -27,7 +27,7 @@
instances into the persistent store (database). Uses Java Data Object Query Language (JDOQL).
</note>
<sample name="XSP" href="jdo/xspdemo">Sample using JDO in a XSP page.</sample>
- <sample name="Woody" href="jdo/woody/employee">Sample using JDO with Woody Binding.</sample>
+ <sample name="Cocoon Forms" href="jdo/forms/employee">Sample using JDO with Cocoon Forms Binding.</sample>
</group>
<group name="Using ODMG 3.0 (To be done)">
@@ -36,13 +36,13 @@
Uses Object Query Language (OQL). ODMG has been superceded by JDO.
</note>
<sample name="XSP" href="odmg/xspdemo">Sample using JDO in a XSP page.</sample>
- <sample name="Woody" href="">Sample using Woody binding. To be done.</sample>
+ <sample name="Cocoon Forms" href="">Sample using Cocoon Forms Binding. To be done.</sample>
</group>
<group name="Using Persistence Broker (To be done)">
<note>Low-level API that can be used directly by applications that don't need full fledged object level transactions.</note>
<sample name="XSP" href="">Sample using JDO in a XSP page. To be done.</sample>
- <sample name="Woody" href="">Sample using Woody binding. To be done.</sample>
+ <sample name="Cocoon Forms" href="">Sample using Cocoon Forms Binding. To be done.</sample>
<sample name="JXForm" href="">Sample using JXForms. To be done.</sample>
</group>
1.1 cocoon-2.1/src/blocks/ojb/samples/forms/employee.js
Index: employee.js
===================================================================
/*
* Copyright 1999-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.
*/
cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js")
function employeeform_jdo(form) {
// Get OJB factory
var factory = cocoon.getComponent(Packages.org.apache.cocoon.ojb.jdo.components.JdoPMF.ROLE);
// Create a empty Bean
var bean = new Packages.org.apache.cocoon.ojb.samples.bean.Employee();
var dao = new Packages.org.apache.cocoon.ojb.samples.EmployeeDAO();
// Fill some initial data to the bean
bean.setId(1);
// Load bean based on the given PrimaryKey
dao.retrieve(bean, factory);
// Load the Bean to the form
form.load(bean);
// Let Cocoon Forms handle the form
form.showForm("jdo/forms/employee-form-display");
// Update the Bean based on user input
form.save(bean);
// Update Bean in Database
dao.update(bean, factory);
// Release the factory
cocoon.releaseComponent(factory);
// Send response to the user
cocoon.request.setAttribute("employeeform", form.getWidget());
cocoon.sendPage("jdo/forms/employee-form-success");
}
1.1 cocoon-2.1/src/blocks/ojb/samples/forms/employee.xml
Index: employee.xml
===================================================================
<?xml version="1.0"?>
<!-- $Id: employee.xml,v 1.1 2004/03/11 16:59:50 stephan Exp $-->
<!--
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Cocoon" and "Apache Software Foundation" must not be used to
endorse or promote products derived from this software without prior
written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
-->
<fd:form xmlns:fd="http://apache.org/cocoon/forms/1.0#definition" xmlns:i18n="http://apache.org/cocoon/i18n/2.1">
<fd:widgets>
<fd:field id="id" required="true">
<fd:label>ID</fd:label>
<fd:datatype base="integer"/>
</fd:field>
<fd:field id="name" required="true">
<fd:label>Name</fd:label>
<fd:datatype base="string">
<fd:validation>
<fd:length min="5"/>
</fd:validation>
</fd:datatype>
</fd:field>
<fd:field id="department_id">
<fd:label>Department ID</fd:label>
<fd:datatype base="integer"/>
</fd:field>
</fd:widgets>
</fd:form>
1.1 cocoon-2.1/src/blocks/ojb/samples/forms/employee_bind.xml
Index: employee_bind.xml
===================================================================
<?xml version="1.0"?>
<!-- $Id: employee_bind.xml,v 1.1 2004/03/11 16:59:50 stephan Exp $-->
<!--
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Cocoon" and "Apache Software Foundation" must not be used to
endorse or promote products derived from this software without prior
written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
-->
<!--
* Employee binding bean
*
* @author <a href="mailto:antonio@apache.org>Antonio Gallardo</a>
* @version CVS $Revision: 1.1 $ $Date: 2004/03/11 16:59:50 $
-->
<fd:context xmlns:fd="http://apache.org/cocoon/forms/1.0#binding" path="/" >
<fd:value id="id" path="id"/>
<fd:value id="name" path="name"/>
<fd:value id="department_id" path="departmentId"/>
</fd:context>
1.1 cocoon-2.1/src/blocks/ojb/samples/forms/employee_template.xml
Index: employee_template.xml
===================================================================
<?xml version="1.0"?>
<!-- $Id: employee_template.xml,v 1.1 2004/03/11 16:59:50 stephan Exp $-->
<!--
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Cocoon" and "Apache Software Foundation" must not be used to
endorse or promote products derived from this software without prior
written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
-->
<!--
* Employee template
*
* @author <a href="mailto:antonio@apache.org>Antonio Gallardo</a>
* @version CVS $Revision: 1.1 $ $Date: 2004/03/11 16:59:50 $
-->
<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template">
<title>Employee</title>
<content>
<ft:form-template action="#{$continuation/id}.continue" method="POST">
<ft:widget-label id="id"/>: <ft:widget id="id"/><br/><br/>
<ft:widget-label id="name"/>: <ft:widget id="name"/><br/><br/>
<ft:widget-label id="department_id"/>: <ft:widget id="department_id"/><br/><br/>
<input type="submit"/>
</ft:form-template>
</content>
</page>
1.1 cocoon-2.1/src/blocks/ojb/samples/forms/success.xsp
Index: success.xsp
===================================================================
<?xml version="1.0"?>
<!--
Copyright 1999-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.
-->
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
<xsp:structure>
<xsp:include>org.apache.cocoon.ojb.jdo.components.JdoPMF</xsp:include>
<xsp:include>org.apache.cocoon.ojb.samples.EmployeeDAO</xsp:include>
<xsp:include>org.apache.cocoon.ojb.samples.bean.Employee</xsp:include>
<xsp:include>org.apache.cocoon.forms.formmodel.*</xsp:include>
</xsp:structure>
<page>
<title>Storing employee in database succeeded.</title>
<content>
<xsp:logic>
Form form = (Form)request.getAttribute("employeeform");
Field fid = (Field)form.getWidget("id");
Field fname = (Field)form.getWidget("name");
Field fdepartment_id = (Field)form.getWidget("department_id");
</xsp:logic>
<p>The values of the form:</p>
ID: <xsp:expr>fid.getValue()</xsp:expr>
<br/>
Name: <xsp:expr>fname.getValue()</xsp:expr>
<br/>
Department ID: <xsp:expr>fdepartment_id.getValue()</xsp:expr>
<hr/>
<p>The values retrieved from the database:</p>
<xsp:logic>
JdoPMF factory = null;
Employee bean = null;
try {
factory = (JdoPMF)manager.lookup(JdoPMF.ROLE);
bean = new Employee();
EmployeeDAO dao = new EmployeeDAO();
bean.setId(((Integer)fid.getValue()).intValue());
dao.retrieve(bean, factory);
} catch (ComponentException ce) {
throw new ProcessingException("Could not lookup JDO PersistanceManagerFactory", ce);
} finally {
if (factory != null) {
manager.release(factory);
}
}
</xsp:logic>
ID: <xsp:expr>bean.getId()</xsp:expr>
<br/>
Name: <xsp:expr>bean.getName()</xsp:expr>
<br/>
Department ID: <xsp:expr>bean.getDepartmentId()</xsp:expr>
</content>
</page>
</xsp:page>
Re: cvs commit: cocoon-2.1/src/blocks/ojb/samples/woody employee.js
employee.xml employee_bind.xml employee_template.xml success.xsp
Posted by Joerg Heinicke <jo...@gmx.de>.
On 11.03.2004 17:59, stephan@apache.org wrote:
> stephan 2004/03/11 08:59:51
>
> Modified: src/blocks/ojb/conf ojb.xsamples
> src/blocks/ojb/samples sitemap.xmap welcome.xml
> Added: src/blocks/ojb/samples/forms employee.js employee.xml
> employee_bind.xml employee_template.xml success.xsp
> Removed: src/blocks/ojb/samples/woody employee.js employee.xml
> employee_bind.xml employee_template.xml success.xsp
> Log:
> Update ojb block to cforms, but seems not to work:
> PersistenceBrokerException: Cannot get Connection from DataSource named null
That's just because of a missing database driver. The stacktrace goes on
with: "No suitable driver". The reason for this is that the patch
cocoon-2.1/src/blocks/hsqldb/conf/hsql.driver.xweb is not applied to
web.xml. I will comment on this on the other thread about XConfToolTask.
Joerg