Spring Webflow部分验证 [英] Spring webflow partial validation

查看:145
本文介绍了Spring Webflow部分验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Spring Webflow 2.4中实现部分验证.根据他们的参考手册,验证应该非常简单地使用组来完成:

I am trying to implement partial validation in Spring Webflow 2.4. According to their reference manual the validation should be done very simply using groups:

@NotNull
@Size(min = 2, max = 30, groups = State1.class)
private String name;

据我所知,State1应该是在其中验证模型的视图状态的ID.因此,flow.xml中此视图状态的定义如下所示:

In my understanding the State1 should be the ID of view-state in which the model should be validated. So the definition of this view state in flow.xml would look like this:

<view-state id="state1" model="modelObject"/>

我试图将State1定义为模型对象的内部类,但没有成功.

I was trying to define the State1 as an inner class of my model object, but without success.

Webflow参考没有提供用于部分验证的完整手册,所以我的问题是:我缺少什么吗?是否有人有使用JSR303小组进行部分验证的经验?

The Webflow reference doesn't provide full manual for partial validation, so my question is: Am I missing something? Does anybody have experience with using the partial validation using JSR303 groups?

谢谢,西蒙

推荐答案

我认为我现在可以回答自己的问题了:)

I think I can answer my own question now :)

问题的根源在于两件事:

The root of the problem was in 2 things:

  1. Group1应该是模型对象的内部接口.因此,模型对象类应如下所示:

  1. The Group1 should be an inner interface of model object. So the model object class should look something like this:

public clas ModelObject{

  @NotEmpty(groups=Group1.class)
  private String field1;

  public interface Group1{}
}

  • od验证提示的名称应使用单引号

  • the name od validation-hint should be in single quotes

    validation-hints="'group1'"
    

  • 这篇关于Spring Webflow部分验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆