Vaadin 组件由于某种原因添加了两次
我正在 Vaadin 框架中开发一个 Web 应用程序。 据我所知,我的应用程序中有一个非常奇怪的行为,希望你们中的一些人熟悉或以其他方式知道如何解决。
这是相关代码:
AbstractComponent horizontalLine = Cf.horizontalLine();
horizontalLine.addStyleName("m2m-horizontal-line-list-separator");
horizontalLine.setWidth("100%");
horizontalLine.setParent(null);
SVerticalLayout spacer = Cf.vLayout(new SLabel(""));
spacer.setMargin(true);
CssLayout cssLayout = new CssLayout();
cssLayout.addStyleName("m2m-css-style");
cssLayout.addComponent(inventoryFilterPanel);
cssLayout.addComponent(horizontalLine);
cssLayout.addComponent(simCardTable);
Panel basePanel = new Panel("");
basePanel.setContent(cssLayout);
basePanel.addStyleName("m2m-base-panel");
basePanel.setSizeFull();
basePanel.getContent().setSizeUndefined();
addStyleName("m2m-tab-main-view");
setMargin(false);
addComponent(basePanel);
setExpandRatio(basePanel, 1);
编辑:添加相关 CSS:
.m2m-horizontal-line-list-separator {
width: 97%;
margin-top: 20px;
margin-bottom: 20px;
}
.m2m-css-style {
margin: 10px;
}
.v-panel-content-m2m-base-panel .v-verticallayout {
min-width: 100%;
}
.m2m-tab-main-view {
/**Didn't have any CSS inside it*/
}
编辑 2:显示问题的图像
编辑 3: Firebug 生成的标记的屏幕截图
在标记中,您会看到: -包含 CssLayout 的面板。 - 在 CssLayout 中,我们有该行的第一个实例,它不应该在那里,也被标记了。 -下面的div是包含filterPanel的VerticalLayout。 - 接下来我们有一行,正确的一行,以及 -终于我们有桌子了。
抽象组件“horizontalLine”充当分隔符来分隔filterPanel 组件和表格。根据代码,它添加了一次,但是,由于浏览器中的某些奇怪原因,它添加了两次。一个实例添加到我想要的位置,另一个实例添加到 cssLayout 的上顶部,高于其他所有内容!疯狂吧!? =P
我不知道为什么会这样。正如您从代码中看到的那样,它只有一个实例,并且仅添加一次......有人知道发生了什么吗?
谢谢! /最大限度
I'm developing a webapplication in the Vaadin framework.
I have according to me a very strange behaviour in my application that some of you hopefully are familiar with or in other ways knows how to work around.
This is the relevant code:
AbstractComponent horizontalLine = Cf.horizontalLine();
horizontalLine.addStyleName("m2m-horizontal-line-list-separator");
horizontalLine.setWidth("100%");
horizontalLine.setParent(null);
SVerticalLayout spacer = Cf.vLayout(new SLabel(""));
spacer.setMargin(true);
CssLayout cssLayout = new CssLayout();
cssLayout.addStyleName("m2m-css-style");
cssLayout.addComponent(inventoryFilterPanel);
cssLayout.addComponent(horizontalLine);
cssLayout.addComponent(simCardTable);
Panel basePanel = new Panel("");
basePanel.setContent(cssLayout);
basePanel.addStyleName("m2m-base-panel");
basePanel.setSizeFull();
basePanel.getContent().setSizeUndefined();
addStyleName("m2m-tab-main-view");
setMargin(false);
addComponent(basePanel);
setExpandRatio(basePanel, 1);
EDIT: Adding relevant CSS:
.m2m-horizontal-line-list-separator {
width: 97%;
margin-top: 20px;
margin-bottom: 20px;
}
.m2m-css-style {
margin: 10px;
}
.v-panel-content-m2m-base-panel .v-verticallayout {
min-width: 100%;
}
.m2m-tab-main-view {
/**Didn't have any CSS inside it*/
}
EDIT 2: Image showing the problem
EDIT 3: Screen shot of the generated markup from Firebug
In the markup you see a:
-Panel containing a CssLayout.
-Inside the CssLayout we have the first instance of the line, which shouldn't be there, which also is marked.
-The following div is the VerticalLayout which contains the filterPanel.
-Next we have the line, the one that is correct, and
-finally we have the table.
The abstract component 'horizontalLine' works as a divider to divide the filterPanel component and the table. According to the code it's added once, however, for some weird reason in the browser it's added two times. One instance is added where I want it to be and another is added in the upper top of the cssLayout, above everything else! Crazy right!? =P
I have no idea why this is. As you see from the code there's only one instance of it, and it's only added once.... Anyone have any idea of what is going on?
Thanks!
/Max
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从您提供的代码中很难说出发生了什么。我的猜测是,实际渲染水平线的 CSS 渗透到其他组件/布局中,或者您的 CSS 规则有错误。
无论如何,请将 CSS 的相关部分添加到问题中,除非您已经弄清楚了。
哈特哈,
/乔纳坦
It's kind of hard to say what's going on from the code you provided. My guess would be that the CSS that actually renders the horizontal line bleeds over into some other component/layout or you have an error in your CSS rules.
Anyhow, please add the relevant parts of your CSS to the question unless you already figured it out.
HTH,
/Jonatan
现在我才注意到您将布局设置为新的面板布局。在您的 CSS 样式“m2m-base-panel”中,您可能不会使用围绕面板内容布局绘制边框来覆盖某些面板基本样式。
尝试添加到您的面板样式
Runo.PANEL_LIGHT
或Reindeer.PANEL_LIGHT
,这应该可以解决您的问题。Only now I notice that you set your layout as new Panel layout. In your CSS style "m2m-base-panel" your may be do not overwrite some of Panel base styles with draw borders around Panel content layout.
Try add to your panel style
Runo.PANEL_LIGHT
orReindeer.PANEL_LIGHT
, this should solve your problem.