如何通过b:commandButton中的oncomplete函数来验证我的表单是否有效? [英] How to validate whether my form is valid from an oncomplete function in a b:commandButton?

查看:64
本文介绍了如何通过b:commandButton中的oncomplete函数来验证我的表单是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven存储库中的bootsfaces 1.3.0,并且试图使用文档中的这个commandButton示例(

I'm using bootsfaces 1.3.0 from maven repository and I'm trying to use this commandButton example that is in the docs (https://showcase.bootsfaces.net/forms/commandButton.jsf):

<b:commandButton 
    value="Ajax Modal" 
    ajax="true" 
    update="form:inform amodal" 
    look="inverse"
    oncomplete="if(validationFailed) alert('Please enter valid input before opening the modal'); else $('#amodal').modal('show')" />

失败,因为它说没有定义validationFailed.有人可以帮助我向我展示如何执行此操作或向我展示文档中的解释位置吗?

It fails because it says validationFailed is not defined. Could somebody help me with showing me how to do this or showing me where it's explained in the docs?

我正在尝试建立一种功能来更改b:modal上的密码,以验证实际密码并检查新密码的有效性.

I'm trying to build a functionality to change passwords on a b:modal validating the actual password and checking password validity of the new one.

我尝试使用隐式对象facesContext,并且检查了是否也可以在bootfaces中使用素数的答案(args.validationFailed).

I've tried using implicit object facesContext, and I've checked if the answer to primefaces (args.validationFailed) could also be used in bootsfaces.

这是我的代码:

<b:commandButton
    value="Change Password"
    action="#{user.changePassword()}"
    ajax="true"
    update="@Form"
    oncomplete="handleDialogSubmit(validationFailed)" />

推荐答案

JavaScript变量validationFailed必须由BootsFaces提供.为此,必须使用<b:fetchBeanInfos />组件.它获取服务器的信息,并使其在客户端可见".

The JavaScript variable validationFailed must be provided by BootsFaces. To accomplish this, you must use the <b:fetchBeanInfos /> component. It takes the server's information and makes it "visible" in the client side.

请参见 https://showcase.bootsfaces.net/forms/FetchBeanInfos.jsf

这篇关于如何通过b:commandButton中的oncomplete函数来验证我的表单是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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