KickJava   Java API By Example, From Geeks To Geeks.

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

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