Search in sources :

Example 1 with Field

use of com.revolsys.ui.html.fields.Field in project com.revolsys.open by revolsys.

the class ObjectElementContainer method validate.

@Override
public boolean validate() {
    boolean valid = true;
    if (this.object != null) {
        for (final Object element : getFields().values()) {
            final Field field = (Field) element;
            if (!field.hasValidationErrors()) {
                final String propertyName = field.getName();
                final Object value = field.getValue();
                try {
                    Property.setSimple(this.object, propertyName, value);
                } catch (final IllegalArgumentException e) {
                    field.addValidationError(e.getMessage());
                    valid = false;
                }
            }
        }
    }
    valid &= super.validate();
    return valid;
}
Also used : Field(com.revolsys.ui.html.fields.Field)

Example 2 with Field

use of com.revolsys.ui.html.fields.Field in project com.revolsys.open by revolsys.

the class FieldNoLabelDecorator method serializeErrors.

protected void serializeErrors(final XmlWriter out, final Element element) {
    if (element instanceof Field) {
        final Field field = (Field) element;
        if (field.hasValidationErrors()) {
            out.startTag(HtmlElem.DIV);
            out.attribute(HtmlAttr.CLASS, "errors");
            for (final Iterator<String> validationErrors = field.getValidationErrors().iterator(); validationErrors.hasNext(); ) {
                final String error = validationErrors.next();
                out.text(error);
                if (validationErrors.hasNext()) {
                    out.text(", ");
                }
            }
            out.endTag(HtmlElem.DIV);
        }
    }
}
Also used : Field(com.revolsys.ui.html.fields.Field)

Example 3 with Field

use of com.revolsys.ui.html.fields.Field in project com.revolsys.open by revolsys.

the class ElementContainer method add.

public ElementContainer add(final Element element) {
    if (element != null) {
        this.elements.add(element);
        element.setContainer(this);
        if (element instanceof Field) {
            final Field field = (Field) element;
            this.fields.put(field.getName(), field);
        } else if (element instanceof ElementContainer) {
            final ElementContainer container = (ElementContainer) element;
            this.containers.add(container);
        }
    }
    return this;
}
Also used : Field(com.revolsys.ui.html.fields.Field)

Example 4 with Field

use of com.revolsys.ui.html.fields.Field in project com.revolsys.open by revolsys.

the class FilterableTableView method initialize.

@Override
public void initialize(final HttpServletRequest request) {
    if (this.searchFields != null) {
        final ElementContainer searchContainer = new ElementContainer(new TableBodyLayout("search", this.model.getColumnCount()));
        add(searchContainer);
        for (final KeySerializer serializer : this.model.getSerializers()) {
            final String name = serializer.getName();
            Element element = this.searchFields.get(name);
            if (element == null) {
                element = NbspElement.INSTANCE;
            } else {
                element = element.clone();
                if (element instanceof Field) {
                    final Field field = (Field) element;
                    field.setRequired(false);
                }
                if (element instanceof TextField) {
                    final TextField textField = (TextField) element;
                    textField.setSize(1);
                }
                if (element instanceof TextAreaField) {
                    final TextAreaField textField = (TextAreaField) element;
                    textField.setRows(1);
                    textField.setCols(1);
                }
            }
            searchContainer.add(element);
        }
    }
    super.initialize(request);
}
Also used : Field(com.revolsys.ui.html.fields.Field) TextField(com.revolsys.ui.html.fields.TextField) TextAreaField(com.revolsys.ui.html.fields.TextAreaField) TableBodyLayout(com.revolsys.ui.html.layout.TableBodyLayout) TextField(com.revolsys.ui.html.fields.TextField) TextAreaField(com.revolsys.ui.html.fields.TextAreaField) KeySerializer(com.revolsys.ui.html.serializer.key.KeySerializer)

Example 5 with Field

use of com.revolsys.ui.html.fields.Field in project com.revolsys.open by revolsys.

the class Form method isValid.

public boolean isValid() {
    boolean success = true;
    for (final Field field : getFields().values()) {
        success &= field.isValid();
    }
    success &= validate();
    this.valid = success;
    return success;
}
Also used : Field(com.revolsys.ui.html.fields.Field)

Aggregations

Field (com.revolsys.ui.html.fields.Field)14 TextField (com.revolsys.ui.html.fields.TextField)3 HiddenField (com.revolsys.ui.html.fields.HiddenField)2 LongField (com.revolsys.ui.html.fields.LongField)2 SetObject (com.revolsys.ui.html.view.SetObject)2 Decorator (com.revolsys.ui.html.decorator.Decorator)1 FieldLabelDecorator (com.revolsys.ui.html.decorator.FieldLabelDecorator)1 FormGroupDecorator (com.revolsys.ui.html.decorator.FormGroupDecorator)1 TextAreaField (com.revolsys.ui.html.fields.TextAreaField)1 TableBodyLayout (com.revolsys.ui.html.layout.TableBodyLayout)1 KeySerializer (com.revolsys.ui.html.serializer.key.KeySerializer)1 ElementLabel (com.revolsys.ui.html.view.ElementLabel)1