001// Copyright 2004, 2005 The Apache Software Foundation 002// 003// Licensed under the Apache License, Version 2.0 (the "License"); 004// you may not use this file except in compliance with the License. 005// You may obtain a copy of the License at 006// 007// http://www.apache.org/licenses/LICENSE-2.0 008// 009// Unless required by applicable law or agreed to in writing, software 010// distributed under the License is distributed on an "AS IS" BASIS, 011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012// See the License for the specific language governing permissions and 013// limitations under the License. 014 015package org.apache.tapestry.form; 016 017/** 018 * Lists different types of JavaScript events that can be associated with a {@link Form} via 019 * {@link Form#addEventHandler(FormEventType, String)}. 020 * 021 * @author Howard Lewis Ship 022 * @since 1.0.2 023 * @deprecated Managing of form events is now done on the client side; this class may be removed in 024 * a future release of Tapestry. 025 */ 026 027public class FormEventType 028{ 029 /** 030 * Form event triggered when the form is submitted. Allows an event handler to perform any final 031 * changes before the results are posted to the server. 032 * <p> 033 * The JavaScript method should return <code>true</code> or <code>false</code>. If there 034 * are multiple event handlers for the form they will be combined using the binary and operator (<code>&&</code>). 035 */ 036 037 public static final FormEventType SUBMIT = new FormEventType("SUBMIT", "onsubmit"); 038 039 /** 040 * Form event triggered when the form is reset; this allows an event handler to deal with any 041 * special cases related to resetting. 042 */ 043 044 public static final FormEventType RESET = new FormEventType("RESET", "onreset"); 045 046 private final String _name; 047 048 private final String _addHandlerFunctionName; 049 050 private FormEventType(String name, String addHandlerFunctionName) 051 { 052 _name = name; 053 _addHandlerFunctionName = addHandlerFunctionName; 054 } 055 056 public String toString() 057 { 058 return "FormEventType[" + _name + "]"; 059 } 060 061 /** 062 * Returns the name of the function, on the Tapestry object (see Form.js), which should be 063 * invoked. The first parameter will be the id of the form, the second will be the handler 064 * itself. 065 */ 066 067 public String getAddHandlerFunctionName() 068 { 069 return _addHandlerFunctionName; 070 } 071}