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