AnsweredAssumed Answered

BooleanFormPropertyRenderer

Question asked by nico1 on Mar 6, 2012
Latest reply on Jul 16, 2012 by frederikheremans1
I'll get onto raising a bug report, but this is just to note that there is an apparent bug in this class in both 5.8 and 5.9, here is the fix:


@Override
  public Field getPropertyField(FormProperty formProperty) {
   
    CheckBox checkBox = new CheckBox(getPropertyLabel(formProperty));
    checkBox.setRequired(formProperty.isRequired());
    checkBox.setEnabled(formProperty.isWritable());

    if (formProperty.getValue() != null) {
      Boolean value = new Boolean(Boolean.parseBoolean(formProperty.getValue())); // bug fix
      checkBox.setValue(value);
    }

    return checkBox;
  }

This is the Exception fixed:


Caused by: java.lang.IllegalArgumentException: CheckBox only accepts Boolean values
        at com.vaadin.ui.Button.setInternalValue(Button.java:546)
        at com.vaadin.ui.AbstractField.setValue(AbstractField.java:493)
        at com.vaadin.ui.AbstractField.setValue(AbstractField.java:451)
        at org.activiti.explorer.ui.form.BooleanFormPropertyRenderer.getPropertyField(BooleanFormPropertyRenderer.java:39)
        at org.activiti.explorer.ui.form.FormPropertiesComponent.setFormProperties(FormPropertiesComponent.java:69)
        at org.activiti.explorer.ui.form.FormPropertiesForm.setFormProperties(FormPropertiesForm.java:75)
        at org.activiti.explorer.ui.task.TaskDetailPanel.initTaskForm(TaskDetailPanel.java:306)
        at org.activiti.explorer.ui.task.TaskDetailPanel.init(TaskDetailPanel.java:118)
        at org.activiti.explorer.ui.task.TaskDetailPanel.attach(TaskDetailPanel.java:99)
        at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:570)
        at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:211)
        at com.vaadin.ui.GridLayout.addComponent(GridLayout.java:223)
        at org.activiti.explorer.ui.AbstractPage.setDetailComponent(AbstractPage.java:137)
        at org.activiti.explorer.ui.task.TaskPage.access$000(TaskPage.java:44)
        at org.activiti.explorer.ui.task.TaskPage$1.valueChange(TaskPage.java:116)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:490)
        … 44 more

Outcomes