Author: antonio
Date: Wed Feb 23 01:30:12 2005
New Revision: 154990
URL: http://svn.apache.org/viewcvs?view=rev&rev=154990
Log:
Add XSP sample for PersistenceBroker
Added:
cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/pb/
cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/pb/xsp/
cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/pb/xsp/demo1.xsp
Modified:
cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/welcome.xml
Added: cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/pb/xsp/demo1.xsp
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/pb/xsp/demo1.xsp?view=auto&rev=154990
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/pb/xsp/demo1.xsp (added)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/pb/xsp/demo1.xsp Wed
Feb 23 01:30:12 2005
@@ -0,0 +1,79 @@
+<?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.
+-->
+
+<!--
+ * Simple demo that insert a row into hsqldb using OJB with PB
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]>Antonio Gallardo</a>
+ * @version CVS $Revision: 1.3 $ $Date: 2004/03/17 11:28:20 $
+-->
+
+<xsp:page language="java" xmlns:xsp="http://apache.org/xsp">
+
+ <xsp:structure>
+
<xsp:include>org.apache.cocoon.ojb.broker.components.PBFactory</xsp:include>
+
<xsp:include>org.apache.cocoon.ojb.samples.bean.Department</xsp:include>
+ <xsp:include>org.apache.ojb.broker.PersistenceBroker</xsp:include>
+ </xsp:structure>
+
+ <xsp:init-page>
+ PBFactory pbFactory = null;
+ PersistenceBroker pb = null;
+ Department bean = new Department();
+ String s;
+ </xsp:init-page>
+
+ <page>
+ <content>
+ <title>Hello OJB</title>
+ <para>This is my first Cocoon page with OJB using Persistence
Broker!</para>
+ <xsp:logic>
+ try {
+ /* Get the PersistenceManager */
+ try {
+ pbFactory = (PBFactory)manager.lookup(PBFactory.ROLE );
+ pb = pbFactory.defaultPersistenceBroker();
+ } catch (ComponentException cme) {
+ getLogger().error("Could not look up
the PB Factory", cme);
+ }
+ <!-- Setting up the Bean -->
+ bean.setId(8);
+ bean.setName("Apache OJB-PB Development");
+ <!-- 2. Start a Transaction -->
+ pb.beginTransaction();
+ <!-- 3. now perform persistence operations.
Store the new Department -->
+ pb.store(bean);
+ <!-- 4. Commit the transaction -->
+ pb.commitTransaction();
+ s = bean.getId() + " : " + bean.getName();
+ </xsp:logic>
+ <p> Inserted data: <xsp:expr>s</xsp:expr>
+ </p>
+ <xsp:logic>
+ } finally {
+ if (pb != null && !pb.isClosed()) {
+ if (pb.isInTransaction()) {
+ pb.abortTransaction();
+ }
+ pb.close();
+ }
+ manager.release(pbFactory);
+ }
+ </xsp:logic>
+ </content>
+ </page>
+</xsp:page>
Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/welcome.xml
URL:
http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/welcome.xml?view=diff&r1=154989&r2=154990
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/welcome.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/ojb/samples/welcome.xml Wed Feb 23
01:30:12 2005
@@ -53,7 +53,7 @@
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="XSP" href="pb/xspdemo">Sample using JDO in a XSP
page.</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>