|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
AbstractFormComponent.java | - | 83.3% | 50% | 75% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.form;
|
|
16 |
|
|
17 |
import org.apache.hivemind.ApplicationRuntimeException;
|
|
18 |
import org.apache.tapestry.AbstractComponent;
|
|
19 |
import org.apache.tapestry.IForm;
|
|
20 |
import org.apache.tapestry.IRequestCycle;
|
|
21 |
import org.apache.tapestry.Tapestry;
|
|
22 |
import org.apache.tapestry.TapestryUtils;
|
|
23 |
import org.apache.tapestry.valid.IValidationDelegate;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* A base class for building components that correspond to HTML form elements.
|
|
27 |
* All such components must be wrapped (directly or indirectly) by
|
|
28 |
* a {@link Form} component.
|
|
29 |
*
|
|
30 |
* @author Howard Lewis Ship
|
|
31 |
* @since 1.0.3
|
|
32 |
*
|
|
33 |
**/
|
|
34 |
|
|
35 |
public abstract class AbstractFormComponent extends AbstractComponent implements IFormComponent |
|
36 |
{ |
|
37 |
/**
|
|
38 |
* Returns the {@link Form} wrapping this component. Invokes
|
|
39 |
* {@link #setForm(IForm)} (so that the component may know, later, what the
|
|
40 |
* form is). Also, if the form has a delegate,
|
|
41 |
* then {@link IValidationDelegate#setFormComponent(IFormComponent)} is invoked.
|
|
42 |
*
|
|
43 |
* @throws ApplicationRuntimeException if the component is not wrapped by a {@link Form}.
|
|
44 |
*
|
|
45 |
**/
|
|
46 |
|
|
47 | 146 |
public IForm getForm(IRequestCycle cycle)
|
48 |
{ |
|
49 | 146 |
IForm result = TapestryUtils.getForm(cycle, this);
|
50 |
|
|
51 | 146 |
setForm(result); |
52 |
|
|
53 | 146 |
IValidationDelegate delegate = result.getDelegate(); |
54 |
|
|
55 | 146 |
delegate.setFormComponent(this);
|
56 |
|
|
57 | 146 |
return result;
|
58 |
} |
|
59 |
|
|
60 |
public abstract IForm getForm();
|
|
61 |
public abstract void setForm(IForm form); |
|
62 |
|
|
63 |
public abstract String getName();
|
|
64 |
public abstract void setName(String name); |
|
65 |
|
|
66 |
/**
|
|
67 |
* Implemented in some subclasses to provide a display name (suitable
|
|
68 |
* for presentation to the user as a label or error message). This implementation
|
|
69 |
* return null.
|
|
70 |
*
|
|
71 |
**/
|
|
72 |
|
|
73 | 0 |
public String getDisplayName()
|
74 |
{ |
|
75 | 0 |
return null; |
76 |
} |
|
77 |
} |
|