简体   繁体   English

在JSF定制组件中,有什么方法可以确保属性包含正确的值?

[英]In a JSF custom component, is there any way to ensure that an attribute contains a correct value?

For example, let's say that I have a component with an attribute called percent . 例如,假设我有一个组件,其属性称为percent This attribute must be an integer from 0-100 , otherwise it makes no sense. 此属性必须是0-1000-100的整数,否则没有任何意义。

If the developer specifies: 如果开发人员指定:

<my:component percent="101" />

Is there any sort of attribute validation available to detect the error and notify the developer of it in JSF? 是否可以使用某种属性验证来检测错误并在JSF中将其通知开发人员?

一种执行此操作的方法(一定会感到有些不舒服)是检查属性在渲染器中是否具有有效值,如果该值无效,则抛出IOException

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM