How to validate whether my form is valid from an oncomplete function in a b:commandButton?

扶醉桌前 提交于 2021-02-05 07:40:38

问题


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')" />

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?

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.

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

This is my code:

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

回答1:


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.

See https://showcase.bootsfaces.net/forms/FetchBeanInfos.jsf



来源:https://stackoverflow.com/questions/53860939/how-to-validate-whether-my-form-is-valid-from-an-oncomplete-function-in-a-bcomm

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!