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 / edit-empl.xsp < prev    next >
Encoding:
Extensible Markup Language  |  2004-07-12  |  4.9 KB  |  119 lines

  1. <?xml version="1.0"?>
  2. <!--
  3.   Copyright 1999-2004 The Apache Software Foundation
  4.  
  5.   Licensed under the Apache License, Version 2.0 (the "License");
  6.   you may not use this file except in compliance with the License.
  7.   You may obtain a copy of the License at
  8.  
  9.       http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11.   Unless required by applicable law or agreed to in writing, software
  12.   distributed under the License is distributed on an "AS IS" BASIS,
  13.   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.   See the License for the specific language governing permissions and
  15.   limitations under the License.
  16. -->
  17.  
  18. <xsp:page xmlns:xsp="http://apache.org/xsp"
  19.           xmlns:xsp-formval="http://apache.org/xsp/form-validator/2.0"
  20.           xmlns:xsp-request="http://apache.org/xsp/request/2.0"
  21.           xmlns:esql="http://apache.org/cocoon/SQL/v2">
  22. <document>
  23.   <header>
  24.     <title>Employee</title>
  25.   </header>
  26.   <body>
  27.     <s1 title="Edit an Employee">
  28.       <form handler="edit-empl.html">
  29.         <p>
  30.           You can edit an employee by changing the
  31.           name and department and pressing the "Update Employee" button.
  32.         </p>
  33.         <parameter name="id">
  34.           <xsp:attribute name="value"><xsp-request:get-parameter name="id"/></xsp:attribute>
  35.         </parameter>
  36.         <esql:connection>
  37.           <esql:pool>personnel</esql:pool>
  38.           <esql:execute-query>
  39.             <esql:query>
  40.               SELECT name, department_id FROM employee
  41.                   WHERE id = <esql:parameter type="int"><xsp:expr>Integer.parseInt(<xsp-request:get-parameter name="id" default="0"/>)</xsp:expr></esql:parameter>
  42.             </esql:query>
  43.             <esql:results>
  44.               <esql:row-results>
  45.                 <p>
  46.                   Name: <text name="name" size="30" required="true">
  47.                   <xsp:attribute name="value"><esql:get-string column="name"/></xsp:attribute>
  48.                   </text><br />
  49.                   <xsp:logic>int deptId = <esql:get-int column="department_id"/>;</xsp:logic>
  50.                   <xsp-formval:on-toosmall name="name">
  51.                     Name must be at least 5 characters.
  52.                   </xsp-formval:on-toosmall>
  53.                   <xsp-formval:on-toolarge name="name">
  54.                     Name must be less than 64 characters.
  55.                   </xsp-formval:on-toolarge>
  56.                 </p>
  57.                 <p>
  58.                   Department:
  59.                   <select name="department">
  60.                   <!-- query execution blocks can be repeated -->
  61.                   <esql:execute-query>
  62.  
  63.                     <!-- Find all departments and order them -->
  64.                     <esql:query>
  65.                       SELECT id, name
  66.                       FROM department ORDER BY name
  67.                     </esql:query>
  68.  
  69.                     <!-- What to do with the results -->
  70.                     <esql:results>
  71.                       <!--
  72.                          A successful query that returns results
  73.                          executes this block.  You can also embed
  74.                          more "execute-query" blocks inside the
  75.                          row-results.  That way you can have queries
  76.                          that filter information based on the results
  77.                          of other queries.
  78.                       -->
  79.                       <esql:row-results>
  80.                         <xsp:logic>
  81.                           if (<esql:get-int column="id"/> == deptId) {
  82.                               xspAttr.addAttribute("", "selected", "selected", "CDATA", "");
  83.                           }
  84.                         </xsp:logic>
  85.                         <option>
  86.                           <xsp:attribute name="value"><esql:get-string column="id"/></xsp:attribute>
  87.                           <esql:get-string column="name"/>
  88.                         </option>
  89.                       </esql:row-results>
  90.                     <!--
  91.                       Other result types are "no-results" and
  92.                       "error-results".  A successful query that
  93.                       does not return results (an empty resultset)
  94.                       will use the XML embedded in the "no-results"
  95.                       section.  An unsuccessful query that throws
  96.                       an exception will use the XML embedded in
  97.                       the "error-results" section.
  98.                     -->
  99.                     </esql:results>
  100.                   </esql:execute-query>
  101.                   </select><br/>
  102.                   <xsp-formval:on-null name="department">
  103.                     You must select a department.
  104.                   </xsp-formval:on-null>
  105.                 </p>
  106.               </esql:row-results>
  107.             </esql:results>
  108.           </esql:execute-query>
  109.         </esql:connection>
  110.         <submit name="Update Employee"/><submit name="Delete Employee"/>
  111.         <note>
  112.           * These fields are required.
  113.         </note>
  114.       </form>
  115.     </s1>
  116.   </body>
  117. </document>
  118. </xsp:page>
  119.