Table getValue return always null

Hi forks,
I encounter a situation when click to a row in the table component, then a Property.ValueChange event is trigger and catch by the Property.ValueChangeListener .
In the event handler function, I use Object rowId =event.getProperty().getValue(); to obtain the rowId however, it always return me the null value.
I have tried and searched the forum, I need help, any suggestion will be appreciated.
Best regards,
tony

The code of the table is list as following:
babyList = new Table();
babyList.setContainerDataSource(ic);
babyList.setWriteThrough(true);
babyList.setHeight(“-1px”);
babyList.setColumnHeaders(COLUMN_HEADERS);
babyList.setVisibleColumns(COLUMN_VISIBLE_HEADERS);
babyList.setCellStyleGenerator(new Table.CellStyleGenerator(){

		public String getStyle(Object itemId, Object propertyId) {
			Item item = babyList.getItem(itemId);
			int event = (Integer)item.getItemProperty(ORDER_BABY_EVENT_PROPERTY_ID).getValue();
			switch(event)
			{
				case 1:
					return "red";
				case 2:
					return "red";
				case 3:
					return "red";
				case 4:
					return "red";
				case 7:
					return "yellow";
				case 8:
					return "yellow";
				case 9:
					return "blue";
				default:
					return "white";						
			}
		}
		
	});
	babyList.addListener(new Property.ValueChangeListener() {
	    public void valueChange(ValueChangeEvent event) {
	    	 //Object rowId = babyList.getValue();
	    	Object rowId =event.getProperty().getValue(); 
	    	if(rowId == null)
	    	{
	    		 System.out.println("rowId == null");
	    	}
	    	 
	    	if(babyList.getContainerProperty(rowId,ORDER_BABY_OBJID_PROPERTY_ID) != null)
	    	{
	    		Long objid = (Long)babyList.getContainerProperty(rowId,ORDER_BABY_OBJID_PROPERTY_ID).getValue();
	    		String name = (String)babyList.getContainerProperty(rowId,ORDER_BABY_NAME_PROPERTY_ID).getValue();                
	    		JSONObject output = new JSONObject();
            	output.put("objid", objid);
            	output.put("name", name);                
            
            	BabySelectedEvent _event = new BabySelectedEvent(output.toString());
            	HeartRateStatusListView.this.bb.fire(_event);
	    	}
	    	else
	    	{
	    		System.out.println("babyList.getContainerProperty(rowId,ORDER_BABY_OBJID_PROPERTY_ID) == null");
	    	}
	    }
	});
	
	babyList.setSelectable(true);		
	babyList.setImmediate(true);

	mainLayout.addComponent(babyList);

I did not fully understand your code but i think you mixed some things. A ValueChangeListener do not react on table click - use ClickListener instead. Furthermore event.getProperty().getValue() may not return the rowId - it returns a cell value.

Thanks for your reply,
In Vaadin table, when I set the table is select-able, every click on the cell will highlight the whole row.
And in theory, I can use the getValue method of the Table to obtain the rowId (I learn from the book of vaadin [https://vaadin.com/book/-/page/components.table.html]
).
In the Vaadin book, it said we can handler the select event by using the Property.ValueChangeListener.
But I just can get the rowId from table getValue method.
Best regards,
tony

It should work and in fact a simple example I tried with Vaadin 6.7.2 works just fine. What version are you using?

6.7.2 in liferay