// the color picker. Notice that we need to convert between RRGGBB and
// #RRGGBB,
// passing in a Color.class param is just a trick to force the component
// to use
// the converter both ways
ColorPickerField textField = new ColorPickerField("paramValue",
paramVale, Color.class) {
@Override
public IConverter getConverter(Class type) {
return new IConverter() {
public String convertToString(Object value, Locale locale) {
String input = (String) value;
if (input.startsWith("#"))
return input.substring(1);
else
return input;
}
public Object convertToObject(String value, Locale locale) {
if (value.equals(""))
return value;
return "#" + value;
}
};
}
};
textField.setRequired(required);
// set the label to be the paramLabelModel otherwise a validation error
// would look like
// "Parameter 'paramValue' is required"
textField.setLabel(paramLabelModel);
if (validators != null) {
for (IValidator validator : validators) {
textField.add(validator);
}
}
FormComponentFeedbackBorder feedback = new FormComponentFeedbackBorder(
"border");
feedback.add(textField);