Extension example not working (Book of vaadin)

Hello,

The extension example in the book of vaadin does not work. I wrote simple extension example so it is not working too. Please help! Maybe i missed something i don’t know. I need help asap. Thanks.
Here is my code.

// TestExtension2UI.java
public class Testextension2UI extends UI {

@Override
    protected void init(VaadinRequest request) {
     final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);

        Label label = new Label("Hello");
        new TestExtension().extend(label);
        layout.addComponent(label);
    }
}

// TestExtension.java
public class TestExtension extends AbstractExtension {
    public void extend(Label target) {    
        super.extend(target);
    }
}

// TestConnector.java
@Connect(TestExtension.class)
public class TestConnector extends AbstractExtensionConnector {
@Override
    protected void extend(ServerConnector target) {
        VLabel label = (VLabel) ((ComponentConnector)target).getWidget();
        Element e = DOM.createDiv();
        e.setInnerHTML("Alohaaaa");
        label.getElement().appendChild(e);
    }
}

Regards,
Emir Cem

Hi,

at a quick glance I don’t see problems in your code. How exactly does it not work? Have you recompiled the widgetset and confirmed from the compiler output that the client-side class of the extension is actually contained in the widgetset?

i recompiled the widgetset then i debug app, extend method in the TestConnector never called. I can’t figure out what is missing.

I found solution.

Widget set compilation, as described in Section 13.3, “Client-Side Module Descriptor”, requires using a special project structure, where the client-side classes are located under a client package under the package of the module descriptor.

Hi,

I copied your code verbatim, compiled the widgetset and ran the application. The extension seems to be called properly, meaning that if I run it in development mode, I get a break point in the client-side extend method triggered.

However, the actual functionality does not work. That’s because your extension sets the inner HTML of the Label to something, and right after that the LabelConnector will set it to “Hello”, wiping away the DIV added by your extension. So I think you need to rework your approach a bit.