executeJavascript on widgets too?

Hi all, is there the equivalent of executeJavascript on widgets too, instead of windows? Or, is it planned for Vaadin 7 or in the future?

That’s because some properties (text alignment into TextFields for example) would IMHO be better handled at code level instead of css level.
For instance, creating a numeric field and putting its text right-formatted is not a matter of “taste” (css) but rather a functionality matter.

Thanks, Marco

I don’t think we will add such a feature to Vaadin 7. Aside from inviting to hacky solutions that are difficult to maintain, the feature as it is implemented in Vaadin 6 is also problematic as the javascript doesn’t get executed again if the user presses refresh in the browser.

For you particular case, I think the best solution is to add a stylename describing the purpose (e.g. “numericField”) to all TextFields that should be right aligned and then adding a CSS rule for .numericField to your theme. In that way the functionality is still controlled through your application logic, but the means for realizing the functionality happens to use some CSS.

One way of using Window.executeJavascript to do things to specific widgets is to give the widget a debugId and then use document.getElementById with executeJavascript to target that specific DOM element. The issue with reloading in the browser does however still remain unsolved.

Thanks, Leif, I already used the CSS-way - and now I can see the point for it being the only one solution :slight_smile:

Thanks again,