001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/
016:
017: /**
018: *
019: */package org.araneaframework.uilib.form;
020:
021: import java.io.Serializable;
022: import org.araneaframework.Scope;
023: import org.araneaframework.Viewable;
024: import org.araneaframework.Widget;
025: import org.araneaframework.uilib.form.control.BaseControl;
026:
027: /**
028: * {@link Control} is the widget that does the actual parsing and reading of the request
029: * parameters. It corresponds to the controls found in HTML forms, like textbox,
030: * textarea, selectbox, button …
031: *
032: * {@link Control} is meant to be used inside {@link FormElement} that provides
033: * type safety and additional {@link Constraint}s to request data.
034: *
035: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
036: */
037: public interface Control extends Widget, Viewable, FormElementAware {
038:
039: /**
040: * Returns whether the control data was present in the HTTP request.
041: *
042: * @return whether the control data was present in the HTTP request.
043: */
044: public boolean isRead();
045:
046: /**
047: * This method should be overriden by the control, returning the type of the value of this
048: * control. It is later used in {@link org.araneaframework.uilib.form.converter.ConverterFactory}to
049: * determine the {@link org.araneaframework.uilib.form.converter.BaseConverter}used to transfer the values
050: * from {@link org.araneaframework.uilib.form.Data}to control and back.
051: *
052: * @return the type of the value of this control
053: */
054: public abstract String getRawValueType();
055:
056: /**
057: * Returns the value of the control (value read from the request). Type of value depends on the
058: * type of control.
059: *
060: * @return Returns the value of the control (value read from the request).
061: */
062: public Object getRawValue();
063:
064: /**
065: * Sets the control value. It is usually set by {@link org.araneaframework.uilib.form.Converter} when
066: * value of {@link FormElement} (this is stored in {@link Data}) that owns this {@link BaseControl} changes.
067: *
068: * @param value control value.
069: * @see #getRawValue()
070: */
071: public void setRawValue(Object value);
072:
073: /**
074: * Converts the data submitted by the user.
075: */
076: public void convert();
077:
078: /**
079: * Validates the data submitted by the user.
080: */
081: public void validate();
082:
083: /** @since 1.1 */
084: public boolean isDisabled();
085:
086: /**
087: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
088: */
089: public interface ViewModel extends Serializable {
090: /**
091: * Returns control type.
092: * @return control type.
093: */
094: public String getControlType();
095:
096: public boolean isMandatory();
097:
098: public String getLabel();
099:
100: public boolean isDisabled();
101:
102: /** @since 1.1 */
103: public Scope getScope();
104: }
105: }
|