Search in sources :

Example 11 with Field

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

the class HtmlUiBuilder method getAttributeLabel.

public Decorator getAttributeLabel(final String key, final Element element) {
    final Map<String, Decorator> fieldLabels = getAttributeLabels();
    Decorator fieldLabel = fieldLabels.get(key);
    if (fieldLabel == null) {
        final String label = getLabel(key, element);
        final String instructions = getAttributeInstruction(key);
        if (element instanceof Field) {
            fieldLabel = new FieldLabelDecorator(label, instructions);
        } else {
            fieldLabel = new ElementLabel(label, instructions);
        }
        fieldLabels.put(key, fieldLabel);
    }
    return fieldLabel;
}
Also used : FieldLabelDecorator(com.revolsys.ui.html.decorator.FieldLabelDecorator) FormGroupDecorator(com.revolsys.ui.html.decorator.FormGroupDecorator) Decorator(com.revolsys.ui.html.decorator.Decorator) LongField(com.revolsys.ui.html.fields.LongField) TextField(com.revolsys.ui.html.fields.TextField) Field(com.revolsys.ui.html.fields.Field) FieldLabelDecorator(com.revolsys.ui.html.decorator.FieldLabelDecorator) ElementLabel(com.revolsys.ui.html.view.ElementLabel)

Example 12 with Field

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

the class FieldLabelDecorator method serialize.

@Override
public void serialize(final XmlWriter out, final Element element) {
    final Field field = (Field) element;
    out.startTag(HtmlElem.DIV);
    out.attribute(HtmlAttr.CLASS, "field");
    serializeLabel(out, field);
    serializeField(out, field);
    serializeInstructions(out);
    serializeErrors(out, field);
    out.endTag(HtmlElem.DIV);
}
Also used : Field(com.revolsys.ui.html.fields.Field)

Example 13 with Field

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

the class FormGroupDecorator method serializeLabel.

protected String serializeLabel(final XmlWriter out, final Element element) {
    final String label = getLabel();
    if (Property.hasValue(label)) {
        out.startTag(HtmlElem.LABEL);
        if (element instanceof Field) {
            final Field field = (Field) element;
            out.attribute(HtmlAttr.FOR, field.getName());
        }
        out.attribute(HtmlAttr.CLASS, "col-sm-3 control-label");
        if (Property.hasValue(this.labelUrl)) {
            out.startTag(HtmlElem.A);
            out.attribute(HtmlAttr.HREF, this.labelUrl);
        }
        out.text(label);
        if (Property.hasValue(this.labelUrl)) {
            out.endTag(HtmlElem.A);
        }
        out.endTag(HtmlElem.LABEL);
        return "col-sm-9";
    } else {
        return "col-sm-12";
    }
}
Also used : Field(com.revolsys.ui.html.fields.Field)

Example 14 with Field

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

the class FormGroupDecorator 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 server-error");
        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)

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