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 015 package org.apache.tapestry; 016 017 import org.apache.tapestry.valid.IValidationDelegate; 018 019 /** 020 * A generic way to access a component which defines an HTML form (or, perhaps, other similar 021 * constructs, such as a WML {@link org.apache.tapestry.wml.Go}). This interface exists so that the 022 * {@link IRequestCycle}can invoke the {@link #rewind(IMarkupWriter, IRequestCycle)}method (which 023 * is used to deal with a Form that uses the direct service). In release 1.0.5, more responsibility 024 * for forms was moved here. 025 * 026 * @author Howard Lewis Ship 027 * @since 1.0.2 028 */ 029 030 public interface IForm extends IComponent, FormBehavior, IDirect 031 { 032 /** 033 * Invoked by the {@link IRequestCycle}to allow a form that uses the direct service, to respond 034 * to the form submission. 035 */ 036 037 void rewind(IMarkupWriter writer, IRequestCycle cycle); 038 039 /** 040 * Returns the name of the form. The name is determined as the form component begins to render, 041 * but is not reset (as a convienience for building client-side JavaScript event handlers). The 042 * Form (and Go) components render this name as both the name and the id attribute (so it can be 043 * used like 044 * {@link org.apache.tapestry.form.IFormComponent#getClientId() a field's clientId property}. 045 * 046 * @since 1.0.5 047 */ 048 049 String getName(); 050 051 /** 052 * Returns the validation delegate for the form. Returns null if the form does not have a 053 * delegate. 054 * 055 * @since 1.0.8 056 */ 057 058 IValidationDelegate getDelegate(); 059 060 /** 061 * Indicates whether or not client-side validation will be generated during render. 062 * 063 * @return true, if client-side validation is enabled, false otherwise 064 * @since 4.0 065 */ 066 boolean isClientValidationEnabled(); 067 068 /** 069 * Returns true if the form should support automatic field focus (that is, adding JavaScript to 070 * position the cursor into the first field of the form, automatically). This requires that the 071 * Form component be enclosed by a {@link org.apache.tapestry.html.Body} component. When a 072 * single page contains multiple Forms, only the first Form that renders will get field focus; 073 * by setting the Form's focus parameter to false, it is possible to control which Form gets 074 * focus. 075 * 076 * @since 4.0 077 */ 078 079 boolean getFocus(); 080 }