我们的目标是创建一种转换器,既能轻松进行扩展来处理额外格式又能尽可能地将任何特定的输入或输出格式的逻辑保持分离。
Your goal is to create a converter that is easy to extend to handle additional formats and that keeps logic for any particular input or output format as separate as possible.
我们偏向后一种方法,因为 它让我们可以将自定义转换器(自带验证逻辑)与特定的对象类型相关联,并让 JSF 处理这种对象类型。
We prefer the latter option because it allows us to simply associate a custom converter (with built-in validation logic) with a specific object type and have JSF handle that object type.
在这种情况下,要么编写自定义验证器,要么在自定义转换器中添加一个特别的验证逻辑。
In this case, you would either have to write a custom validator, as well, or simply include any special validation logic in the custom converter.
应用推荐