ClientSide Extension with Own SharedState

Hi all,

I try write an extension for a Textfield. As I like to introduce a new State I am not sure on how to proceed.

Do I need to extend the Vaadin-AbstractTextFieldState and include my new State (A boolean Flag) that I want to read out in the ClientConector or is the getState from the TextField/Wiched indipendend from the getState of teh Connector/Extension.

The Book of Vaadin is not that informative about that one, just states that they can use States in the sameway as componets can.

So far I tried to use an independend getState but then the I don’t get the StateChanged infos from the TextField.

Any Idea on how what I should look for?

Regards
Marc

Hi Marc,

Yes, the Extension state is independent from the extended Component’s state, so you should just write a state class that extends the base SharedState class (there’s no special “ExtensionState” class at least currently). If additionally you want to listen to the parent TextField’s state changes, just call one of the TextFieldConnector’s addStateChangeHandler methods in your extension connector’s init method.

Hi Hohannes,

thanks for the Answer, so I don’t have to try to find a way to use the same state.
So what i did now is follow:

protected void extend(ServerConnector target) { target.addStateChangeHandler(new StateChangeEvent.StateChangeHandler() { works for the StateChanges of the Parent. But somehow if I overwrite the getState()-Method in the Connector the extend(ServerConnector target) and and public void onAttachOrDetach(AttachEvent event) are not called anymore.

The overwritten getState() would retourn my own State-Object that extends AbstractComponentState.

Regards
Marc

Ok just figured out my mistake.

I only need to move the SharedState-Object into my widget.client folder and there it works now.

Not really a GWT and clientside development crack, but could I also put the state class in a package with the name shared? And if so also needs to be under widgetset or any place in the package would be fine?

Thanks
Marc