2

I have some experience with GWT . In GWT , widget.setVisible() method will add style="display:none" style to widget. But component of vaadin wouldn't . I checked with firebug , I can't see my component while set component's visible to false. Why ?

I think that should be also have hidden style instead of not containing. I reallize that vaadin's codes were server side. But sometimes , if I would like to just hidden (set style display to none) , has there anyway to accomplish this instead of using css ?

I don't understand concept of what different between without adding component and setVisible(false) ?

4

2 回答 2

4

正如您已经注意到的,一个不可见的组件不会从服务器传输到浏览器,并且从浏览器的角度来看,该组件不存在。这种方法有好处:

  1. 从服务器传输到客户端的数据更少
  2. 安全性:用户无法使用 Firebug 等工具检查不可见组件生成的 HTML,因为浏览器上不存在这些工具。

所以基本上从浏览器的角度来看,你根本不将它添加到 UI 中是一样的。但通常更容易切换组件的可见性,而不是从其父级添加和删除它。

如果你想用 CSS 隐藏组件,你可以通过定义你自己的主题并在那里添加一个样式来实现。然后只需使用该方法为要隐藏的组件应用样式即可addStyleName

于 2014-08-01T16:59:21.173 回答
2

SETVISIBLE设置组件的可见性。

Visible components are drawn in the user interface, while invisible ones are not. The effect is not merely a cosmetic CSS change - no information about an invisible component will be sent to the client. The effect is thus the same as removing the component from its parent.

因此,正如文档所说,不可见的组件是不可见的。

于 2014-08-01T05:11:21.167 回答