Table + ColumnGenerator + HorizontalLayout with Label + Click

Hi!

I have the following generator

    public static class DomainProblemColumnGenerator implements ColumnGenerator {
        private static final long serialVersionUID = 1L;

        private String valuePropertyId;
        private String diagPropertyId;
        
        public DomainProblemColumnGenerator(String column) {
            this.valuePropertyId = column;
            this.diagPropertyId = String.format("%s_diag", column);
        }
        
        @Override
        public Object generateCell(final Table source, final Object itemId,
                Object columnId) {
            Item item = source.getItem(itemId);
            if( item != null ) {
                Property<?> valueProperty = item.getItemProperty(valuePropertyId);
                Property<?> diagProperty = item.getItemProperty(diagPropertyId);
                Label label = new Label(valueProperty);
                label.setWidth(null);
                if( diagProperty.getValue() instanceof String ) {
                    label.setDescription(diagProperty.getValue().toString());
                    Label icon = new Label();
                    icon.setDescription(diagProperty.getValue().toString());
                    icon.setIcon(forwarder.getThemeResource("import/error.png"));
                    icon.setWidth("16px");
                    icon.setHeight("16px");
                    HorizontalLayout l = new HorizontalLayout(icon, label);
                    l.setHeight("16px");
                    l.addLayoutClickListener(new LayoutClickListener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void layoutClick(LayoutClickEvent event) {
                            source.setValue(itemId);
                        }
                    });
                    return l;
                }
                return label;
            }
            
            return null;
        }
    }

I want select table row when I click on the label object. But my layout does not recieve LayoutClickEvent when I press on the label.

What’s wrong? Thank you for any hint!

BR,
AnatolyS

Hi,

I think the Table will eat all click events on labels in the client side, so the layout can never receive it. Easiest fix should be this add-on:
http://vaadin.com/directory/#addon/tableclickforwarder:vaadin

-tepi