How to add a CSS style ID (not only CSS style class) in Vaadin

I would like that my Vaadin components be set a style id:

<div id="menu"> ... </div>

and not only a style class:

<div class="menu"> ... </div>

Anyone have an idea? Thanks.


So you would want to set an ID yourself, or that Vaadin set them for you?

You can set ID's yourself using the setDebugId method for each component instance. Do note, that each ID should be unique for each individual component instance.


We can use the id which set with setDebugId() method in production mode also.
I opened a ticket about that (http://dev.vaadin.com/ticket/7867), and response is i can use those ids in production mode also.
Then i made a small demo application and i saw the ids were there in production mode :)


The old setDebugId(id) method was deprecated since Vaadin 7.0.

You can use the setId(id) method.

The new method name "setId" is better than old name "setDebugId", because it is not only working in DEBUG mode, but also in PRODUCTION mode.

链接地址: http://www.djcxy.com/p/4784.html

上一篇: 贝宝修改订阅

下一篇: 如何在Vaadin中添加CSS样式ID(不仅是CSS样式类)