Java 使用fieldgroup property vaadin进行验证

Java 使用fieldgroup property vaadin进行验证,java,web,frameworks,vaadin,Java,Web,Frameworks,Vaadin,我有这个文本字段 firstNameField = new TextField("First Name"); firstNameField.setRequired(true); firstNameField.setImmediate(true); firstNameField.setValidationVisible(true); firstNameField.setWidth(COMMON_FIELD_WIDTH); firstNameField.

我有这个文本字段

   firstNameField = new TextField("First Name");
    firstNameField.setRequired(true);
    firstNameField.setImmediate(true);
    firstNameField.setValidationVisible(true);
    firstNameField.setWidth(COMMON_FIELD_WIDTH);
    firstNameField.addValidator(new StringLengthValidator(
            "Allowed Length of Characters(2-30) ", 2, 30, true));

    firstNameField.setNullRepresentation(null);
此字段绑定到bean属性firstName

  binderFieldGroupPersonalDetails.bind(firstNameField, "firstName");
现在当我使用

  binderFieldGroupPersonalDetails.commit;
提交时图标没有验证错误
但是,如果将鼠标悬停在区域上,则会显示requirederror

如何向用户提示空字段?
我试过这个

   Button.ClickListener btnSaveContinuePersonalDetailsClickListener = new Button.ClickListener() {

    public void buttonClick(ClickEvent event) {
        try {
            // changes
                // the
                // tab
                // layout
                // to
                // next
                // tab
                // on
                // Successful
                // commit
            binderFieldGroupPersonalDetails.commit();
            TabSheetLayout
                    .setSelectedTab(contentAccountDetailsRegistrationForm);

        } catch (CommitException e) {


            //lets add up all the error msg for missing fields
            Collection<Field<?>> fields = binderFieldGroupPersonalDetails.getFields();
            Iterator<Field<?>> it = fields.iterator();
            String errorMessage = "";
            while(it.hasNext()){
                if(it.next().getValue()==null||it.next().getValue()==""){
                    errorMessage=errorMessage.concat("  "+it.next().getCaption()+" is required <br>");

                }
            }
            getUI().showNotification("<h6>"+errorMessage+"<h6>",Notification.TYPE_ERROR_MESSAGE);

                e.printStackTrace();
        }

    }
};  
Button.ClickListener btnSaveContinuePersonalDetailsClickListener=新建按钮。ClickListener(){
公共作废按钮单击(单击事件){
试一试{
//变化
//
//标签
//布局
//到
//下一个
//标签
//在
//成功的
//承诺
binderFieldGroupPersonalDetails.commit();
选项卡布局
.setSelectedTab(内容账户详情登记表);
}捕获(委员会){
//让我们为缺少的字段添加所有错误消息
Collection>it=fields.iterator();
字符串errorMessage=“”;
while(it.hasNext()){
if(it.next().getValue()==null | | it.next().getValue()==“”){
errorMessage=errorMessage.concat(“+it.next().getCaption()+”是必需的
”; } } getUI().showNotification(“+errorMessage+”,Notification.TYPE\u ERROR\u MESSAGE); e、 printStackTrace(); } } };
如何获取fieldgroupfactory的哪些文件尝试使用空/空值提交???Vaadin本身会突出显示那些未通过验证的字段。见示例:
binderFieldGroupPersonalDetails.setBuffered(true);

// A button to commit the buffer
button.addComponent(new Button("OK", new ClickListener() {
    @Override
    public void buttonClick(ClickEvent event) {
        try {
            binder.commit();
            Notification.show("Thanks!");
        } catch (CommitException e) {
            Notification.show(e.getMessage());
        }
    }
}));