KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > woody > formmodel > SubmitDefinitionBuilder


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 package org.apache.cocoon.woody.formmodel;
17
18 import org.apache.cocoon.woody.util.DomHelper;
19 import org.w3c.dom.Element JavaDoc;
20
21 /**
22  * Builds a <code>&lt;wd:submit></code> widget. A submit is an action that terminates
23  * the current form. It can either require the form to be valid (in which case it will
24  * be redisplayed if not valid) or terminate it without validation (e.g. a "cancel" button).
25  * <p>
26  * The syntax is as follows :
27  * <pre>
28  * &lt;wd:submit id="sub-id" action-command="cmd" validate="false">
29  * </pre>
30  * The "validate" attribute can have the value <code>true</code> or <code>false</code>
31  * and determines if the form is to be validated (defaults to true).
32  *
33  * @author <a HREF="http://www.apache.org/~sylvain/">Sylvain Wallez</a>
34  * @version CVS $Id: SubmitDefinitionBuilder.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class SubmitDefinitionBuilder extends ActionDefinitionBuilder {
37     
38     public WidgetDefinition buildWidgetDefinition(Element JavaDoc widgetElement) throws Exception JavaDoc {
39         
40         SubmitDefinition definition = (SubmitDefinition)super.buildWidgetDefinition(widgetElement);
41         definition.setValidateForm(DomHelper.getAttributeAsBoolean(widgetElement, "validate", true));
42         return definition;
43     }
44
45     protected ActionDefinition createDefinition() {
46         return new SubmitDefinition();
47     }
48 }
49
Popular Tags