home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-cocoon-addon-1.4.9-installer.exe / employee.js < prev    next >
Encoding:
Text File  |  2004-07-12  |  1.6 KB  |  47 lines

  1. /*
  2. * Copyright 1999-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. *     http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. cocoon.load("resource://org/apache/cocoon/forms/flow/javascript/Form.js")
  17.  
  18. function employeeform_jdo(form) {
  19.     // Get OJB factory
  20.     var factory = cocoon.getComponent(Packages.org.apache.cocoon.ojb.jdo.components.JdoPMF.ROLE);
  21.  
  22.     // Create a empty Bean
  23.     var bean = new Packages.org.apache.cocoon.ojb.samples.bean.Employee();
  24.     var dao = new Packages.org.apache.cocoon.ojb.samples.EmployeeDAO();
  25.  
  26.     // Fill some initial data to the bean
  27.     bean.setId(1);
  28.     // Load bean based on the given PrimaryKey
  29.     dao.retrieve(bean, factory);
  30.  
  31.     // Load the Bean to the form
  32.     form.load(bean);
  33.     // Let Cocoon Forms handle the form
  34.     form.showForm("jdo/forms/employee-form-display");
  35.     // Update the Bean based on user input
  36.     form.save(bean);
  37.  
  38.     // Update Bean in Database
  39.     dao.update(bean, factory);
  40.     // Release the factory
  41.     cocoon.releaseComponent(factory);
  42.  
  43.     // Send response to the user
  44.     cocoon.request.setAttribute("employeeform", form.getWidget());
  45.     cocoon.sendPage("jdo/forms/employee-form-success");
  46. }
  47.