Enable and Disable table component from outside component

Hi sir,

       In my vaadin project , i  have used one Table . Table contains  Label for two columns and Textfield for two columns .Outside the table i have one Combobox .
      If I change the value of the outside combobox  ,  i have to enable or disable two textfield of the particular row . Here is my code

[code]

          [left]

// This my table
tblMd.addContainerProperty(“Shift”,Label.class,null);
tblMd.addContainerProperty(“Start Time”, Label.class, null);
tblMd.addContainerProperty(“Code”,TextField.class, null);
tblMd.addContainerProperty(“Duration (min)”, TextField.class,null);
tblMd.setPageLength(5);
for (int j = 0; j < 4; j++)
{
lb = new Label(shift[j]
);
lb.setImmediate(true);
lb.setWidth(“80px”);
lb1 = new Label(startTime[j]
);
lb1.setImmediate(true);
lb1.setWidth(“80px”);
tx = new TextField();
tx.setWidth(“80px”);
tx.setValue(i);
tx.setImmediate(true);
tx1 = new TextField();
tx1.setWidth(“80px”);
tx1.setValue(++i);
tx1.setImmediate(true);
if(j == 3)
{
comboBox_3.setData(tx); //
Here i have some doubts

}
tblMd.addItem(new Object{lb,lb1,tx,tx1},new Integer(j));//
tblMd.requestRepaint();
}

            // This is my outside combobox
            comboBox_3.addItem("3");
	comboBox_3.addItem("4");
	comboBox_3.select("3");	
	comboBox_3.setNullSelectionAllowed(false);
	comboBox_3.addListener(this);

           //This is combobox event
           public void valueChange(ValueChangeEvent event) 
       {
	      // TODO Auto-generated method stub
	      getWindow().showNotification(""+event.getProperty().getValue());
	     if(event.getProperty().getValue().equals(4))
	     {
		 ComboBox cbx = (ComboBox)event.getProperty();
                     if(cbx.getValue().equals(4))
                     {
                              TextField associatedTextField = (TextField)cbx.getData();
                              //Do all your stuff with the TextField
                               associatedTextField.setReadOnly(false);
                      }
		tblMd.requestRepaint();
	     }
       }

[/code]
[/left]

Please give me some solution for this sir.


final Container container = new IndexedContainer();
container.addContainerProperty("Shift",Label.class,null);
container.addContainerProperty("Start Time", Label.class,  null);
container.addContainerProperty("Code",TextField.class, null);
container.addContainerProperty("Duration (min)", TextField.class,null);

Table tbl = new Table();
tbl.setContainerDataSource(container);

ComboBox combo = new ComboBox();
combo.setContainerDataSource(container);

combo.addListener(new Property.ValueChangeListener() {
    public void valueChange(ValueChangeEvent event) {
        TextField tf = (TextField) container.getContainerProperty(event.getProperty().getValue(), "Duration (min)").getValue();
         // Do whatever
    }
});

Sir ,

       The code you gave me  was very  helpful to me .  I should use Container for table while using components inside the table and controlling that components from outside.

Thank you sir.

Sir ,

Actually i have used your code today. But its not working .

       This is my code 

      [code]

            container = new IndexedContainer();
	container.addContainerProperty("Shift",Label.class,null);
	container.addContainerProperty("Start Time", Label.class,  null);
	container.addContainerProperty("Code",TextField.class, null);
	container.addContainerProperty("Duration (min)", TextField.class,null);	
	tblMd.setPageLength(5);
	tblMd.setEditable(true);
	tblMd.setSelectable(true);
	tblMd.setContainerDataSource(container);

            comboBox_3.setNullSelectionAllowed(false);
	comboBox_3.addItem("3");
	comboBox_3.addItem("4");
	comboBox_3.select("3");
	comboBox_3.setContainerDataSource(container);
	
	comboBox_3.addListener(new Property.ValueChangeListener() 
	{
		public void valueChange(ValueChangeEvent event) 
		{
			String value = event.getProperty().getValue().toString();
			getWindow().showNotification(""+value);
			if(value.equals("3"))
			{	
				addItemToTable(3);			
			}
			if(value.equals("4"))
			{
				TextField tf = (TextField) container.getContainerProperty(event.getProperty().getValue(), "Duration (min)").getValue();

				tf.setEnabled(true) // [b]

Here is Null pointer Exception is thrown.
[/b]
}

		}
	});
	addItemToTable(4);

[/code]

while clicking the combobox it throws error like this
com.vaadin.event.ListenerMethod$MethodException: Invocation of method valueChange in xpsSystemSettings.XPSMillDetails$2 failed. Caused by: java.lang.NullPointerException

and also the item in combobox are added with a item id of Table. Here i added 3,4 but combobox shows 0,1,2,3,3,4.

How do solve this problem ?