Example usage for org.apache.wicket.util.string Strings toBoolean

List of usage examples for org.apache.wicket.util.string Strings toBoolean

Introduction

In this page you can find the example usage for org.apache.wicket.util.string Strings toBoolean.

Prototype

public static Boolean toBoolean(final String s) throws StringValueConversionException 

Source Link

Document

Converts the string s to a Boolean.

Usage

From source file:com.userweave.components.authorization.AuthOnlyCheckBox.java

License:Open Source License

/**
 * @see org.apache.wicket.markup.html.form.FormComponent#convertValue(String[])
 *//*from   w w  w  .  ja  va  2  s  . co m*/
@Override
protected Object convertValue(String[] value) {
    String tmp = value != null && value.length > 0 ? value[0] : null;
    try {
        return Strings.toBoolean(tmp);
    } catch (StringValueConversionException e) {
        throw new ConversionException("Invalid boolean input value posted \"" + getInput() + "\"", e)
                .setTargetType(Boolean.class);
    }
}

From source file:org.artifactory.common.wicket.component.checkbox.styled.StyledCheckbox.java

License:Open Source License

private static Boolean toBoolean(String[] value) throws ConversionException {
    String tmp = value != null && value.length > 0 ? value[0] : null;
    try {/* w w w . j ava2s.co m*/
        return Strings.toBoolean(tmp);
    } catch (StringValueConversionException e) {
        final ConversionException conversionException = new ConversionException(
                String.format("Invalid boolean input value posted \"%s\"", tmp), e);
        conversionException.setTargetType(Boolean.class);
        throw conversionException;
    }
}