java – Vaadin – 如果我使用AbsoluteLayout,则不显示表数据
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – Vaadin – 如果我使用AbsoluteLayout,则不显示表数据,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3270字,纯文字阅读大概需要5分钟。
内容图文
目前我面临着与Vaadin Table相当奇怪的问题.如果我在表中使用AbsoluteLayout数据没有显示,但如果我使用,即Horizo??ntalLayout,数据就会完美显示.
这有效:
import com.vaadin.annotations.AutoGenerated;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Table;
public class MyComposite extends CustomComponent {
@AutoGenerated
private HorizontalLayout mainLayout;
@AutoGenerated
private Table table;
public MyComposite() {
buildMainLayout();
setCompositionRoot(mainLayout);
// TODO add user code here
table.addContainerProperty("First Name", String.class, null);
table.addContainerProperty("Last Name", String.class, null);
table.addContainerProperty("Year", Integer.class, null);
table.addItem(new Object[] { "Nicolaus", "Copernicus",
new Integer(1473) }, new Integer(1));
table.addItem(new Object[] { "Tycho", "Brahe", new Integer(1546) },
new Integer(2));
}
@AutoGenerated
private HorizontalLayout buildMainLayout() {
// common part: create layout
mainLayout = new HorizontalLayout();
mainLayout.setStyleName("blue");
mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
mainLayout.setMargin(false);
// top-level component properties
setWidth("100.0%");
setHeight("100.0%");
// table
table = new Table();
table.setImmediate(false);
table.setWidth("100.0%");
table.setHeight("100.0%");
mainLayout.addComponent(table);
return mainLayout;
}
}
但这不是:
import com.vaadin.annotations.AutoGenerated;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Table;
public class MyComposite extends CustomComponent {
@AutoGenerated
private AbsoluteLayout mainLayout;
@AutoGenerated
private Table table;
public MyComposite() {
buildMainLayout();
setCompositionRoot(mainLayout);
// TODO add user code here
table.addContainerProperty("First Name", String.class, null);
table.addContainerProperty("Last Name", String.class, null);
table.addContainerProperty("Year", Integer.class, null);
table.addItem(new Object[] { "Nicolaus", "Copernicus",
new Integer(1473) }, new Integer(1));
table.addItem(new Object[] { "Tycho", "Brahe", new Integer(1546) },
new Integer(2));
}
@AutoGenerated
private AbsoluteLayout buildMainLayout() {
// common part: create layout
mainLayout = new AbsoluteLayout();
mainLayout.setStyleName("blue");
mainLayout.setImmediate(false);
mainLayout.setWidth("100%");
mainLayout.setHeight("100%");
// top-level component properties
setWidth("100.0%");
setHeight("100.0%");
// table
table = new Table();
table.setImmediate(false);
table.setWidth("100.0%");
table.setHeight("100.0%");
mainLayout.addComponent(table);
return mainLayout;
}
}
两种情况都显示列的名称.有人能告诉我为什么会这样吗?提前致谢.
解决方法:
我能够重现你的问题.似乎Vaadin的家伙在这里描述了原因:
Vaadin book
引用:
A layout that contains components with percentual size must have a defined size!
If a layout has undefined size and a contained component has, say, 100% size, the component will try to fill the space given by the layout, while the layout will shrink to fit the space taken by the component, which is a paradox. This requirement holds for height and width separately. The debug mode allows detecting such invalid cases; see Section 11.3.5, “Inspecting Component Hierarchy”
对于AbsoluteLayout,到目前为止我找到的唯一解决方法是将表格尺寸设置为某个固定值.
内容总结
以上是互联网集市为您收集整理的java – Vaadin – 如果我使用AbsoluteLayout,则不显示表数据全部内容,希望文章能够帮你解决java – Vaadin – 如果我使用AbsoluteLayout,则不显示表数据所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。