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;
}
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);
}
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";
}
}
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);
}
}
Aggregations