Example usage for org.apache.wicket.markup.html.form FormComponent setModelValue

List of usage examples for org.apache.wicket.markup.html.form FormComponent setModelValue

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form FormComponent setModelValue.

Prototype

public void setModelValue(final String[] value) 

Source Link

Document

Sets the value for a form component.

Usage

From source file:com.googlecode.wicketwebbeans.fields.AbstractField.java

License:Apache License

protected void setFieldParameters(FormComponent field) {
    Integer maxLength = getMaxLength();
    if (maxLength != null) {
        field.add(new SimpleAttributeModifier("maxlength", maxLength.toString()));
    }//from  w  w w  .ja v a  2 s  .c o m

    String defaultValue = getDefaultValue();
    if (defaultValue != null && Strings.isEmpty(getDefaultModelObjectAsString())) {
        field.setModelValue(defaultValue);
    }
}

From source file:org.artifactory.common.wicket.util.ComponentPersister.java

License:Open Source License

/**
 * Override wicket's cookie utils to enable encoding and decoding of cookie content.
 * See RTFACT-6086/*from w  w w  .j  a  v a2 s  .c  o m*/
 * @param formComponent
 * @return
 */
protected static String load(final FormComponent<?> formComponent) {
    String value = COOKIE_UTILS.load(formComponent.getPageRelativePath());
    if (value != null) {
        // Assign the retrieved/persisted value to the component
        String[] values = value.split(FormComponent.VALUE_SEPARATOR);
        for (int i = 0; i < values.length; i++) {
            try {
                values[i] = URLDecoder.decode(values[i], "UTF-8");
            } catch (UnsupportedEncodingException e) {
                log.debug("Failed to decode cookie value: {}", e.getMessage());
            }
        }
        formComponent.setModelValue(values);
    }
    return value;
}