ReadOnly textfields are not ReadOnly when bound using a FieldGroup and when value of a property is changed, it doesn’t reflect it on the UI.
package org.example.test;
import com.vaadin.data.fieldgroup.FieldGroup;
import com.vaadin.data.util.ObjectProperty;
import com.vaadin.data.util.PropertysetItem;
import com.vaadin.server.*;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
public class NavigatorTest extends UI
{
@Override
protected void init(VaadinRequest request)
{
setContent(new TestFieldGroup());
}
}
class TestFieldGroup extends VerticalLayout
{
private TextField notReadOnly = new TextField("Not Readonly");
private TextField readOnly = new TextField("ReadOnly");
public TestFieldGroup()
{
readOnly.setReadOnly(true);
final PropertysetItem item = new PropertysetItem();
item.addItemProperty("Editable", new ObjectProperty<String>("Should be editable"));
item.addItemProperty("Locked", new ObjectProperty<String>("Should NOT be editable"));
FieldGroup binder = new FieldGroup(item);
binder.bind(notReadOnly, "Editable");
binder.bind(readOnly, "Locked");
addComponent(notReadOnly);
addComponent(readOnly);
addComponent(new Button("Change Text", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event)
{
item.getItemProperty("Editable").setValue("Value Changed");
}
}));
}
}