ItemClickListener() doesn't work after using setCellStyleGenerator

I have a problem with it working on Vaadin 6.7.1

I set cell style for my table.


table.setCellStyleGenerator(new Table.CellStyleGenerator() {
public String getStyle(Object itemId, Object propertyId) {		    	
		    	if (Integer.parseInt(dbHelp.getTaskContainer().getItem(itemId).getItemProperty("StatusId").getValue().toString()) == com.enumerators.TaskStatus.Completed.getValue()) {
			    	return "green";
		    	} else {
		    		return "green";
		    	}
		    }
		}); 

CSS file has this:


.v-table-cell-content-green {
    background: green;
    color: white;
}

There is my listener:


table.addListener(new ItemClickListener() {
			@Override
			public void itemClick(ItemClickEvent event) {
				if (event.isDoubleClick()) {
					TaskBusinessObject tbo = dbHelp.getTaskItem(event.getItemId());
					mdw = getTaskWindow(tbo);
					mdw.getContent().setSizeUndefined();
					getWindow().getApplication().getMainWindow().addWindow(mdw);
				}
				table.requestRepaintAll();
			}});

If I change cellStyleGenerator to this:


table.setCellStyleGenerator(new Table.CellStyleGenerator() {
public String getStyle(Object itemId, Object propertyId) {		    	
		    	return "green";
		    }
		}); 

Then it works.

I tested that with Vaadin 6.8.10 and there weren’t these issues. But I need to use 6.7.1 version because it is compatible with some of add-ons I am using and the newer versions are not. How to fix it?

You didn’t write anywhere on what the problem is. The cells doesn’t get the “green” style with the first cellstylelistener (first code example) but does with the second cellstylelistener (last code example)?

To me it seems that both should in all cases return “green”. If the result differs, and there is nothing else that changes, then the only reason to it that I can come up with is that your code throws an exception and never get executed. You have quite many chained calls in:
dbHelp.getTaskContainer().getItem(itemId).getItemProperty(“StatusId”).getValue().toString()

are you sure none of these returns null, which in turn would throw an NullPointerException.

Sorry :slight_smile: I read my post again and saw that I haven’t written there the problem is :slight_smile:

The cells get the “green” and work fine with the style. But after changing a style ItemClickListener() doesn’t work. It doesn’t work neither with click nor with doubleClick. If I change setStyleGenerator and remove “if” statement then ItemClickListener() works.


table.setCellStyleGenerator(new Table.CellStyleGenerator() {
public String getStyle(Object itemId, Object propertyId) {                
                return "green";
            }
        }); 

But if I add “if” as I wrote before, ItemClickListener() doesn’t work…

Sounds like a bug to me. Can you make a minimal test case? An Application class with as little code as possible to demostrate the problem. Then you could file a bug at
dev.vaadin.com
about it.