Search in sources :

Example 6 with Field

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

the class UiBuilderObjectForm method validate.

@Override
public boolean validate() {
    boolean valid = true;
    if (this.object != null) {
        for (final Field field : getFields().values()) {
            if (!field.hasValidationErrors() && !field.isReadOnly()) {
                final String propertyName = field.getName();
                if (propertyName != Form.FORM_TASK_PARAM && this.fieldKeys.contains(propertyName)) {
                    final Object value = field.getValue();
                    try {
                        this.builder.setValue(this.object, propertyName, value);
                    } catch (final IllegalArgumentException e) {
                        field.addValidationError(e.getMessage());
                        valid = false;
                    }
                }
            }
        }
        if (valid) {
            valid &= this.builder.validateForm(this);
        }
    }
    valid &= super.validate();
    return valid;
}
Also used : Field(com.revolsys.ui.html.fields.Field) HiddenField(com.revolsys.ui.html.fields.HiddenField) SetObject(com.revolsys.ui.html.view.SetObject)

Example 7 with Field

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

the class HtmlUiBuilderObjectForm method validate.

@Override
public boolean validate() {
    boolean valid = true;
    if (this.object != null) {
        for (final Field field : getFields().values()) {
            if (!field.hasValidationErrors() && !field.isReadOnly()) {
                final String propertyName = field.getName();
                if (propertyName != Form.FORM_TASK_PARAM && this.fieldKeys.contains(propertyName)) {
                    final Object value = field.getValue();
                    try {
                        this.builder.setValue(this.object, propertyName, value);
                    } catch (final IllegalArgumentException e) {
                        field.addValidationError(e.getMessage());
                        valid = false;
                    }
                }
            }
        }
        if (valid) {
            valid &= this.builder.validateForm(this);
        }
    }
    valid &= super.validate();
    return valid;
}
Also used : Field(com.revolsys.ui.html.fields.Field) HiddenField(com.revolsys.ui.html.fields.HiddenField) SetObject(com.revolsys.ui.html.view.SetObject)

Example 8 with Field

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

the class Form method initialize.

@Override
public void initialize(final HttpServletRequest request) {
    if (this.action == null || this.action.trim().length() == 0) {
        this.action = URL_HELPER.getOriginatingRequestUri(request);
    }
    // ensure the formTaskField is initialized first so that it can be used
    // by the other fields
    this.formTask = request.getParameter(FORM_TASK_PARAM);
    final String method = request.getMethod();
    this.posted = method.equalsIgnoreCase(POST_METHOD);
    preInit(request);
    super.initialize(request);
    final Map<String, Field> fieldMap = getFields();
    final Collection<Field> fields = fieldMap.values();
    for (final Field field : fields) {
        field.initialize(this, request);
    }
    for (final Field field : fields) {
        field.postInit(request);
    }
    final Map<String, String[]> parameters = getActionParameters(request);
    this.action = UrlUtil.getUrl(this.action, parameters);
}
Also used : Field(com.revolsys.ui.html.fields.Field)

Example 9 with Field

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

the class FormGroupInstructionsDecorator method serializeErrors.

protected void serializeErrors(final XmlWriter out, final Element element) {
    if (element instanceof Field) {
        final Field field = (Field) element;
        out.startTag(HtmlElem.DIV);
        out.attribute(HtmlAttr.CLASS, "help-block with-errors");
        out.closeStartTag();
        for (final String error : field.getValidationErrors()) {
            out.startTag(HtmlElem.DIV);
            out.text(error);
            out.endTag(HtmlElem.DIV);
        }
        out.endTag(HtmlElem.DIV);
    }
}
Also used : Field(com.revolsys.ui.html.fields.Field)

Example 10 with Field

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

the class HtmlUiBuilder method getLabel.

public String getLabel(final String key, final Element element) {
    final Map<String, String> labels = getLabels();
    String label = labels.get(key);
    if (label == null) {
        if (element instanceof Field) {
            final Field field = (Field) element;
            label = field.getLabel();
        }
        if (label == null) {
            return getLabel(key);
        } else {
            labels.put(key, label);
        }
    }
    return label;
}
Also used : LongField(com.revolsys.ui.html.fields.LongField) TextField(com.revolsys.ui.html.fields.TextField) 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