| <?xml version="1.0"?> |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You 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.JDO</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.lookupWidget("id"); |
| Field fname = (Field) form.lookupWidget("name"); |
| Field fdepartment_id = (Field) form.lookupWidget("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> |
| JDO factory = null; |
| Employee bean = null; |
| try { |
| factory = (JDO) manager.lookup(JDO.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> |