{
@SuppressWarnings("unchecked")
@Override
public void onFormComponent(FormComponent<?> formComponent2, IVisit<Void> visit)
{
final FormComponent formComponent=formComponent2;
// do nothing for invisible component
if (!formComponent.isVisibleInHierarchy())
{
return;
}
// if component is text field and do not have exist value, fill
// blank String if required
if (formComponent instanceof AbstractTextComponent)
{
if (Strings.isEmpty(formComponent.getValue()))
{
if (fillBlankString)
{
setFormComponentValue(formComponent, "");
}
}
else
{
setFormComponentValue(formComponent, formComponent.getValue());
}
}
else if ((formComponent instanceof DropDownChoice) ||
(formComponent instanceof RadioChoice) || (formComponent instanceof CheckBox))
{
setFormComponentValue(formComponent, formComponent.getValue());
}
else if (formComponent instanceof ListMultipleChoice)
{
final String[] modelValues = formComponent.getValue().split(
FormComponent.VALUE_SEPARATOR);
for (String modelValue : modelValues)
{
addFormComponentValue(formComponent, modelValue);
}
}
else if (formComponent instanceof CheckGroup)
{
final Collection<?> checkGroupValues = (Collection<?>)formComponent.getDefaultModelObject();
formComponent.visitChildren(Check.class, new IVisitor<Component, Void>()
{
public void component(final Component component, final IVisit<Void> visit)
{
if (checkGroupValues.contains(component.getDefaultModelObject()))
{
addFormComponentValue(formComponent,
((Check<?>)component).getValue());
}
}
});
}
else if (formComponent instanceof RadioGroup)
{
// TODO 1.5: see if all these transformations can be factored out into
// checkgroup/radiogroup by them implementing some sort of interface {
// getValue(); } otherwise all these implementation details leak into the tester
final Object value = formComponent.getDefaultModelObject();
if (value != null)
{
formComponent.visitChildren(Radio.class, new IVisitor<Component, Void>()
{
public void component(final Component component,
final IVisit<Void> visit)
{
if (value.equals(component.getDefaultModelObject()))