TextField f = new TextField();
Button b = new Button("Save");
b.setClickShortcut(KeyCode.ENTER); // For quick saving from text field itself
TextArea longText = new TextArea(); // "Enter" is garbled here
Run Code Online (Sandbox Code Playgroud)
热门使快捷方式仅在from文本字段中起作用?
我的组合框的实例是全局创建的,它被填充,让我们说一个公司列表,而值是一个ID.加载文件后,我想在组合框中检查我是否有该值,然后以编程方式选择它.
class cComboBoxFun extends UI implements ClickListener
{
ComboBox cb_company;
List<cCustomer> ListCust;
//default constructor and server conf not really relevant
@Override
protected void init(VaadinRequest request)
{
//Lets assume the list has been filled already
cb_company = new ComboBox("Company");
for(cCustomer cust : ListCust)
{
cb_company.addItem(cust.mgetId);
cb_company.setItemcaption(cust.mgetId, cust.mgetName);
}
}
class cCustomer()
{
private String name;
private String Id;
public String GetName()
{
return this.name
}
// Same for id
}
Run Code Online (Sandbox Code Playgroud)
我试着检查值是否存在并设置它但没有任何反应.我抬头但找不到答案
if(cb_company.getItemCaption(value) != null)
cb_company.set(value);
Run Code Online (Sandbox Code Playgroud) 我希望框架能够捕获每个未捕获的异常并显示适当的通知消息.
因此,我ErrorHandler在我的UI中设置了一个自定义(受到"Vaadin之书"的启发:https://vaadin.com/book/-/page/application.errors.html ):
public abstract class MyUI extends UI {
@Override
protected void init(final VaadinRequest request) {
setErrorHandler(new DefaultErrorHandler() {
@Override
public void error(final com.vaadin.server.ErrorEvent event) {
Throwable error = event.getThrowable();
Notification.show(error.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我从后端加载错误时它没有被执行.相反,表单显示不完整,当我重新加载页面(F5)时,我得到一个异常视图,就像我从Tomcat的常规异常处理程序中知道的那样.
我设置它是不对的ErrorHandler?有没有更好的办法?
我正在使用Glassfish 4和Vaadin 7.
我应该向具有BeanItemContainer数据源的表添加一列.
这是我的情况:
我有一个实体bean
@Entity
public class MyBean implements {
@Id
private Long id;
//other properties
Run Code Online (Sandbox Code Playgroud)
}
然后在我的vaadin面板中我有这个方法
private Table makeTable(){
Table table = new Table();
tableContainer = new BeanItemContainer<MyBean>(MyBean.class);
table.setContainerDataSource(tableContainer);
table.setHeight("100px");
table.setSelectable(true);
return table;
}
Run Code Online (Sandbox Code Playgroud)
现在,我想添加一个列,使我能够删除此容器中的项目.
我能怎么做?
我使用vaadin(7.1.9)的上传组件,现在我的问题是,我不能够限制什么样的可以与上传组件向服务器发送的文件,但我还没有发现任何用于此目的的API.唯一的方法是在上传后丢弃错误类型的文件.
public OutputStream receiveUpload(String filename, String mimeType) {
if(!checkIfAValidType(filename)){
upload.interruptUpload();
}
return out;
}
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
setDelayMSec(-1)表示在用户单击消息框之前显示消息.当用户点击外面的任何地方时,我可以关闭消息框吗?
假设我有允许输入的组合框。我想限制输入,例如,用户只能输入10个字符。我该怎么做?谢谢。
我正在研究遗留项目,它是一个Vaadin组件,它使用Maven YUI插件来缩小和连接javascript文件.有40个js文件.
YUI插件可以正常工作,缩小40个js文件并将它们连接成一个文件(然后@javascript在Vaadin中引用).
由于新功能的缩小开发很痛苦,但我无法删除YUI插件,因为那时我需要@javascript为所有40个js文件添加注释.
有没有办法让YUI聚合而不是缩小.我已经阅读了文档并试图改变目标(即仅限于jslint),但如果我不使用compress目标,我似乎无法聚合.
我在这里错过了什么吗?
这是我的YUI配置:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<id>jslint</id>
<goals>
<goal>jslint</goal>
</goals>
<configuration>
<includes>
<include>**/*.js</include>
</includes>
<excludes>
<exclude>**/VAADIN/js/*.js</exclude>
<exclude>**/depends/*.js</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>minify</id>
<goals>
<goal>compress</goal>
</goals>
<configuration>
<nosuffix>true</nosuffix>
<force>true</force>
<excludeWarSourceDirectory>true</excludeWarSourceDirectory>
<linebreakpos>-1</linebreakpos>
<aggregations>
<aggregation>
<inputDir>target/classes/[path]/components</inputDir>
<removeIncluded>true</removeIncluded>
<output>${project.build.directory}/classes/[path].js</output>
<includes>
<include>**/*.js</include>
<include>**/Copyright.txt</include>
</includes>
<excludes>
<exclude>**/depends/d3_3.4.6.js</exclude>
</excludes>
</aggregation>
</aggregations>
<includes>
<include>**/*.js</include>
<include>**/[project.name].css</include>
</includes>
<excludes>
<exclude>**/depends/*.js</exclude>
</excludes>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
Nb我也在jslint目标中使用聚合配置尝试了上述内容,没有任何乐趣.
必须有一种方法来停止压缩(我知道YUI是一个压缩插件,但它有其他功能(如lint),所以我假设你可以关闭压缩).此外,Vaadin的@javascript注释采用逗号分隔的js文件列表.我觉得添加40会太多了,但也许有一种方法@javascript可以获取一个目录.(虽然文档没有提到这一点)