Problem creating custom widget extending CustomLayout

Hi,

I am developing a web application with vaadin and I want to create a widget based in CustomLayout. I create a widget through the “New Component Wizard” selecting as superclass “com.vaadin.ui.AbstractComponent”. I call the new Widget TextEditorlayout.

It creates the client an server rpcs, the widget and the connector. The problem comes when I try to define the HTML to show. It does not show the desired string, but a text defined in the widget.

This is the “TextEditorLayout.java”:

[code]
package com.application.widgets;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import com.application.widgets.client.texteditorlayout.TextEditorLayoutServerRpc;
import com.application.widgets.client.texteditorlayout.TextEditorLayoutState;

public class TextEditorLayout extends com.vaadin.ui.CustomLayout {
private static final long serialVersionUID = -535606792L;

private static String textoDiv = "<div class=\"text_element\" label=\"Algo\"> Something </div>";

private TextEditorLayoutServerRpc rpc = new TextEditorLayoutServerRpc() {
    private static final long serialVersionUID = 2521893261681364418L;
};  

/**
 * Constructor of text editor
 * 
 * @throws IOException 
 */
public TextEditorLayout() throws IOException  {
    /*Add the html to the component*/
    super(new ByteArrayInputStream(textoDiv.getBytes()));
    registerRpc(rpc);
    this.setStyleName("text_editor");
}

@Override
public TextEditorLayoutState getState() {
    return (TextEditorLayoutState) super.getState();
}

}
[/code]This is the “TextEditorLayoutConnector.java”:

[code]
package com.application.widgets.client.texteditorlayout;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;

import com.vaadin.client.ui.AbstractComponentConnector;
import com.vaadin.shared.ui.Connect;

import com.application.widgets.TextEditorLayout;
import com.application.widgets.client.texteditorlayout.TextEditorLayoutWidget;
import com.application.widgets.client.texteditorlayout.TextEditorLayoutServerRpc;
import com.vaadin.client.communication.RpcProxy;
import com.application.widgets.client.texteditorlayout.TextEditorLayoutClientRpc;
import com.application.widgets.client.texteditorlayout.TextEditorLayoutState;
import com.vaadin.client.communication.StateChangeEvent;

@Connect(TextEditorLayout.class)
public class TextEditorLayoutConnector extends AbstractComponentConnector {
private static final long serialVersionUID = -9138509048818642858L;
TextEditorLayoutServerRpc rpc = RpcProxy
.create(TextEditorLayoutServerRpc.class, this);

public TextEditorLayoutConnector() {
    registerRpc(TextEditorLayoutClientRpc.class, new TextEditorLayoutClientRpc() {
        private static final long serialVersionUID = 7560147797186683349L;
    });

}

@Override
protected Widget createWidget() {
    return GWT.create(TextEditorLayoutWidget.class);
}

@Override
public TextEditorLayoutWidget getWidget() {
    return (TextEditorLayoutWidget) super.getWidget();
}

@Override
public TextEditorLayoutState getState() {
    return (TextEditorLayoutState) super.getState();
}

@Override
public void onStateChanged(StateChangeEvent stateChangeEvent) {
    //super.onStateChanged(stateChangeEvent);


    final String text = getState().text;
    getWidget().setText(text);
}

}
[/code]And this is the “TextEditorLayoutWidget.java”:[code]
package com.application.widgets.client.texteditorlayout;

import com.google.gwt.user.client.ui.Label;

public class TextEditorLayoutWidget extends Label {

public static final String CLASSNAME = "texteditorlayout";

public TextEditorLayoutWidget() {

    setText("TextEditorLayout sets the text via TextEditorLayoutConnector using TextEditorLayoutState");
    setStyleName(CLASSNAME);

}

}
[/code]The text that appears is “This is TextEditorLayout”, which is defined in “TextEditorLayoutState.java”:[code]
package com.application.widgets.client.texteditorlayout;

public class TextEditorLayoutState extends com.vaadin.shared.ui.customlayout.CustomLayoutState {
private static final long serialVersionUID = -4219761654452930311L;
public String text = “This is TextEditorLayout o algo”;

}
[/code]I try to modify the text showing through the method

initTemplateContentsFromInputStream(new ByteArrayInputStream(textoDiv.getBytes())); But it does not work.

Also I try to access to setTemplateContents directly but neither works

this.setTemplateContents(textoDiv);

Being new in widgets and Vaadin, i hope you can solve my problem.

Thaks in advance.

I finally solved it making my own widget and connecting it to an abstractComponent.