×

Please give details of the problem

Skip to content

How to get the list of invalid fields of a web interface

  • Create an html widget that will display the list of invalid fields of your web interface and set its id to id_html_invalid_widgets

  • Add a JavaScript widget with this script:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    function displayInvalidFields(){
    var invalidWidgetsHtml = '<span style="color:red">';
    var invalidWidgetsInArray = {};
    RMPApplication.getInvalidWidgets().forEach(function(invalidWidget){
        try{
            if(invalidWidget.isIndexed()){
                // the widget is inside an Array
                var arrayId = invalidWidget.getParent().getName();
                if( !(invalidWidgetsInArray[arrayId]) ){
                    invalidWidgetsInArray[arrayId] = {};
                }
                if( !(invalidWidgetsInArray[arrayId][invalidWidget.getIndex()]) ){
                    invalidWidgetsInArray[arrayId][invalidWidget.getIndex()] = new Array;
                }
                var columnHeader = invalidWidget.getParent().getHeader( invalidWidget.getContainerIndex());
                invalidWidgetsInArray[arrayId][invalidWidget.getIndex()].push( columnHeader );
    
            }else if( invalidWidget.getParent()!=null && invalidWidget.getParent().getType()=="RMP_TabPanel" ){
                // the invalid widget is inside a TabPanel, we display the tab index that contains the widget and its label
                invalidWidgetsHtml += '<li>' + invalidWidget.getParent().getTabLabel( invalidWidget.getContainerIndex())   +' > ' + invalidWidget.getLabel() + '</li>';
    
            }else if( invalidWidget.getParent()!=null && invalidWidget.getParent().getType()=="RMP_Section" ){
                // we display the label of the section that contains the widget and its owne label
                invalidWidgetsHtml += '<li>' + invalidWidget.getParent().getLabel()   +' > ' + invalidWidget.getLabel() + '</li>';
    
            }else{
                invalidWidgetsHtml += '<li>' + invalidWidget.getLabel() + '</li>';
            }
        }catch(error){
            // display the raised errors on the browser console
            console.log(error);
        }
    });
    // we display the invalid fields of each line of the invalid arrays
    for ( var arrayId in invalidWidgetsInArray ){
        invalidWidgetsHtml += '<li>' + arrayId + '<ul>';
        for( var ligneIndex in invalidWidgetsInArray[arrayId] ){
            var invalidColumnHeaders = invalidWidgetsInArray[arrayId][ligneIndex]; 
            invalidWidgetsHtml += '<li> Ligne ' + ligneIndex + ': '+ invalidColumnHeaders + '</li>';
        }
        invalidWidgetsHtml += '</ul></li>';
    }
    invalidWidgetsHtml += '</span>';
    //display the invalid fields in an Html widget
    id_html_invalid_widgets.setHtml(invalidWidgetsHtml);
    }
    
  • Call displayInvalidWidgets() function whenever you want to display the list of invalid fields of your web interface

how-to-use-google-table

A non valid field is a field that either:

  • don't respect its valid rule
  • is required and is not filled in