How to maintain an open dialogue?

0

This is my XHTML of buttons in a dialog, and I do not know how to avoid closing the dialog when I give it to save and the data I have it in required, I explain: I want that when pressing save and inputText are empty the dialog is closed, but if they are full, it will close     

<p:commandButton value="Guardar" icon="fa fa-save" 
actionListener="#{soporteTipoBean.guardarSoporteDocumental}" 
process="@this id_main:panelParamSop" update="id_main:msgs 
id_main:nombreNitIPS 
id_main:dt_ConsultaSoporte"

styleClass="GreenButton" oncomplete="PF('NewParamet').hide();"  
onclick="PrimeFaces.cleanWatermarks()">
<p:resetInput 
target="panelParamSop" />
</p:commandButton>
    
asked by Juan 27.07.2018 в 23:04
source

2 answers

0

I thank @Garrizano because he gave me the idea of how to find the solution

<p:commandButton value="Guardar" 
                 icon="fa fa-save" 
                 actionListener="#{soporteTipoBean.guardarSoporteDocumental}"                                                                      
                 process="@this id_main:panelParamSop" 
                 update="id_main:msgs id_main:nombreNitIPS id_main:dt_ConsultaSoporte id_main:newParamSopor" 
                 styleClass="GreenButton"
                 oncomplete="handleLoginRequest(xhr, status, args)"
                 >
                 <script type="text/javascript">
                  function handleLoginRequest(xhr, status, args) {
                  if(args.validationFailed) {
                      PF('nombreWidgetVar').show();
                  }else {
                   PF('nombreWidgetVar').hide();
                      }
                  }
                  </script>
    
answered by 02.08.2018 / 14:53
source
0

I use JavaScript. These are the functions I use:

/**
 * 
 * @param {type} xhr
 * @param {type} status
 * @param {type} args
 * @param {type} dialogName
 * @param {type} formName
 * @param {type} widgetName
 * @returns {undefined}
 */
function handleSubmitRequest(xhr, status, args, dialogName, formName, widgetName) {
    dialog = jQuery('#' + dialogName);
    if (args.validationFailed) {
        dialog.effect("shake", {times: 3}, 200);
    } else {
        clearForm(formName);
        widgetName.hide();
    }
}

/**
 * 
 * @param {type} formName
 * @returns {undefined}
 */
function clearForm(formName) {
    jQuery('#' + formName).each(function() {
        this.reset();
    });
}

And on the button where the save is executed, I call the function handleSubmitRequest in this way:

oncomplete="handleSubmitRequest(xhr, status, args, 'idDeDialogo','idDeFormularioDentroDeDialogo', PF('widgetVarDeDialogo'));"

You could add Javascript functions in a .js file and load it in your view to use it in multiple views.

    
answered by 31.07.2018 в 16:28