Example usage for org.apache.wicket.util.lang Objects stringValue

List of usage examples for org.apache.wicket.util.lang Objects stringValue

Introduction

In this page you can find the example usage for org.apache.wicket.util.lang Objects stringValue.

Prototype

public static String stringValue(final Object value, final boolean trim) 

Source Link

Document

Evaluates the given object as a String and trims it if the trim flag is true.

Usage

From source file:eu.uqasar.web.pages.qmtree.metric.QMMetricFormValidator.java

License:Apache License

@Override
public void validate(Form<?> form) {
    final FormComponent name = components[0];
    final FormComponent<Double> lowerLimit = components[1];
    final FormComponent<Double> upperLimit = components[2];

    Localizer loc = getLocalizer(form);/*from   w ww  .j  a va  2  s. co  m*/
    String nameValue = Objects.stringValue(name.getInput(), true);

    if ("".equals(nameValue)) {
        name.error(loc.getString("form.name.required", name));
    } else if (nameValue.length() > 255) {
        name.error(loc.getString("form.name.max", name));
    }

    //         if (Double.valueOf(lowerLimit.getValue()) > Double.valueOf(upperLimit.getValue())){
    //            upperLimit.error(loc.getString("form.upperLimit.low", upperLimit));
    //         }
}

From source file:eu.uqasar.web.pages.qmtree.qmodels.QModelFormValidator.java

License:Apache License

@Override
public void validate(Form<?> form) {
    final FormComponent name = components[0];
    final FormComponent key = components[1];
    final boolean isNew = newEntity;
    final String oldKey = previousKey;

    Localizer loc = getLocalizer(form);/*www  . j a v  a2  s  . c  om*/
    String f1Value = Objects.stringValue(name.getInput(), true);
    String f2Value = Objects.stringValue(key.getInput(), true);

    if ("".equals(f1Value)) {
        name.error(loc.getString("form.name.required", name));
    } else if (f1Value.length() > 255) {
        name.error(loc.getString("form.name.max", name));
    }
    if ("".equals(f2Value)) {
        key.error(loc.getString("form.key.required", key));
    }

    List<String> nodeKeyList = qmodelService.getAllNodeKeys();
    if (!previousKey.equals(f2Value) && !isNew && Collections.frequency(nodeKeyList, f2Value) >= 1) {
        key.error(loc.getString("form.key.repeated", key));
    } else if (!previousKey.equals(f2Value) && isNew && (Collections.frequency(nodeKeyList, f2Value) > 0)) {
        key.error(loc.getString("form.key.repeated", key));
    }
}

From source file:eu.uqasar.web.pages.qmtree.quality.indicator.QMQualityIndicatorFormValidator.java

License:Apache License

@Override
public void validate(Form<?> form) {
    final FormComponent name = components[0];
    final FormComponent<Double> lowerLimit = components[1];
    final FormComponent<Double> upperLimit = components[2];

    Localizer loc = getLocalizer(form);/*from   w w  w  .  ja va  2 s  . c om*/
    String f1Value = Objects.stringValue(name.getInput(), true);
    if ("".equals(f1Value)) {
        name.error(loc.getString("form.name.required", name));
    } else if (f1Value.length() > 255) {
        name.error(loc.getString("form.name.max", name));
    }

    //         if (Double.valueOf(lowerLimit.getValue()) > Double.valueOf(upperLimit.getValue())){
    //            upperLimit.error(loc.getString("form.upperLimit.low", upperLimit));
    //         }
}