JSF在哪里验证输入值?后端还是前端? [英] Where does JSF validate the input values? Back-End or Front-end?

查看:157
本文介绍了JSF在哪里验证输入值?后端还是前端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

JSF可以验证输入值.有人可以说JSF在哪里验证..

JSF can validate the input values. Can anybody say where JSF validates..?

推荐答案

我认为两个答案都不清楚,因此我想总结一下:

I think both answers are a bit unclear, therefore I would like to summarize:

1.)按原样使用JSF,总是在服务器端执行验证! JSF中的验证是JSF组件生命周期的一部分.提交某些数据时会触发生命周期.我不想详细介绍,但是生命周期遍历了phsaes(还原组件,触发转换,验证转换后的值,执行动作侦听器和操作,呈现响应)

1.) JSF as it is, always performs the validation on server side! Validation in JSF is a part of JSF component lifecycle. The life-cycle is triggered when you submit some data. I do not want to go in details but the life-cycle goes through the phsaes (Restore the component, trigger conversions, validate the converted values, execute actionlisteners and actions, render the reponse)

2.)感觉就像是客户端站点验证的验证是在JSF中使用ajax支持时进行的.此方法的作用是仅请求执行某些html字段. JSF执行与普通请求相同的生命周期.不同之处在于,它仅转换和验证您指定的组件,并且仅针对您指定的组件呈现输出. 因此,JSF中Ajax支持的验证也在服务器端执行!

2.) The validation that feels like client-site validation is when you use ajax support in JSF. What this method does is that it requests the execution of only some html fields. JSF performs the same life-cycle as for the ordinary requests. The difference is that it converts and validates only the components you specify, and renders the output only for components you specified. Therefore, ajax supported validation in JSF is also preformed on the server-side!

3.)我不同意第三方库提供客户端验证.

3.) I have to disagree that third-party libraries provide client-side validation.

Primefaces 集成了jQuery UI,但仍使用ajax方法来验证数据.您可以编写自己的jQuery JS来验证某些字段,但我不会这样做.编写起来很痛苦,而且很难管理重复的验证逻辑.

Primefaces integrates jQuery UI, but it still uses the ajax aproach to validate data. You can write your own jQuery JS to validate certain field, but I would not do it. It is painful to write and hard to manage duplicated validation logic.

Richfaces 提供了部分客户端验证.它为某些JSR 303和JSF验证器提供JS实现.因此,提供了真正的客户端JS验证,但仅针对存在JS实现的验证器.请参阅: http://planet.jboss.org/post/richfaces_4_client_side_validation

Richfaces provides partial client-side validation. It provides JS implementation for some of the JSR 303 and JSF validators. Therefore, real client-side JS validation is provided, but only for the validators for which JS implementation exists. See: http://planet.jboss.org/post/richfaces_4_client_side_validation

冰面,因为它是Primefaces克隆,不提供客户端验证.

Ice faces as being a Primefaces clone do not provide client-side validation.

这篇关于JSF在哪里验证输入值?后端还是前端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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