Question regarding client side development - Add server-side component

Hello,

I am currently developing a client side component and I’m currently stuck with a problem, I hope somebody is able to help me.
In our project we needed a custom table component with gantt capabilities. So I have created such a component with extended Widget/AbstractComponentConnector/AbstractComponent classes.
Now i need to add an editor form to our component. I don’t want to code this editor in GWT, I’d rather just use a “normal” Vaadin component acting on the server side.
But I’m very unsure, how I can accomplish this. I know that I can exchange Connector objects in the components state and I’m already doing that. But what is the general pattern for doing this after a users action? So I catch a click in my client component. Then I would need the server to know that and deliver the editor component. Since the server RPC cannot return values, would I also do this with the components state? Where on the server side would I add this editor component in the hierarchy?
On the client side I would want to do something like

this.editorLayout = (VFormLayout) connector.getWidget(); widget.getPopupPanelDiv().appendChild(this.editorLayout.getElement()); assuming the connector is the servers editor component connector.

I hope the description is not too blurry…If it is I would try to explain it in more detail again.
Thanks in advance!

Hi,

I think the most “vaadin way” of doing this is to change your superclasses to AbstractComponentContainer and AbstractComponentContainerConnector. This way you get the handling and methods for adding components from the framework.

Once you’ve done this you’ll need to implement a new method in your connector: onConnectorHierarchyChange. When this is called you know that a component has been added/removed to your component. After that point you are free to add the new components and remove the old components as you wish (see methods from com.vaadin.client.ConnectorHierarchyChangeEvent).

Please find a more thorough example at
https://vaadin.com/wiki/-/wiki/Main/Creating+a+simple+component+container

-tepi