How to use Vaadin components in custom GWT widgets?

Hi,

i want create a new widget which will include some vSliders.
The current state is, that i have added the elements of the sliders as childs to the element of my widget.

	/**
	 * Called whenever an update is received from the server
	 */
	public void updateFromUIDL(final UIDL uidl, final ApplicationConnection client) {
		// This call should be made first.
		// It handles sizes, captions, tooltips, etc. automatically.
		if(client.updateComponent(this, uidl, true)) {
			// If client.updateComponent returns true there has been no changes and we
			// do not need to update anything.
			return;
		}
		
		// Save reference to server connection object to be able to send
		// user interaction later
		this.client = client;
		
		// Save the client side identifier (paintable id) for the widget
		this.paintableId = uidl.getId();
		
		// TODO replace dummy code with actual component logic
		getElement().appendChild(new VSlider().getElement());
		getElement().appendChild(new VSlider().getElement());
		getElement().appendChild(new VSlider().getElement());
		getElement().appendChild(new VSlider().getElement());
		
	}

The result after adding the sliders

Ok, the sliders should have some configurations, but the vSlider can only be updated by UIDL and im not able to create a new
UIDL
instance with some values, because there are no setter for attributes.

Is there a way to solve this problem?
12233.png

There is no good solution to you problem using Vaadin 6.x. Most client side implementations, including VSlider, are tightly coupled to their server side counterpart. Even if you would manage to create a suitable mock UIDL to pass to the slider, your next problem would be that the VSlider sends value changes directly to the server in the updateValueToServer method. This could in theory be solved by passing your own implementation of ApplicationConnection that intercepts the calls to updateVariable instead of sending them to the server.

This is one of the areas that will be improved in Vaadin 7, though there will probably not be enough time to update all the built in components to work as stand alone components without a direct server side counterpart for the 7.0.0 release. The framework level changes enabling this kind of transition is however mostly in place in recent nightly builds.

In your case, it would probably be easier to instead make your own copy of the VSlider code where you remove the dependencies on UIDL and ApplicationConnection.

Please also note that the way you attach the DOM elements of the VSliders directly to the DOM element of your own widget will probably cause problems as it doesn’t update GWT’s widget hierarchy. You should instead make your widget extend from e.g. GWT’s ComplexPanel and use one of its add methods to add the widgets.