OW2 Consortium telosys

Rev

Rev 20 | Blame | Compare with Previous | Last modification | View Log | RSS feed

//------------------------------------------------------------------------------
// Screen_class.js
// Telosys framework
// Author  : Laurent Guérin 
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
// "Screen" Object 
//------------------------------------------------------------------------------
function Screen(argScreenName, argAjaxUrl, argScreenId )
{
        //==============================================================================
        // STANDARD ATTRIBUTES & METHODS
        //==============================================================================
        var _bTrace = false ;
        //------------------------------------------------------------------------------
        function _trace ( sMsg ) 
        {
                if ( _bTrace ) alert ( "TRACE [Screen] :\n\n" + sMsg ) ;
        }
        //------------------------------------------------------------------------------
        function _error ( sMsg ) 
        {
                alert ( "ERROR [Screen] :\n\n" + sMsg ) ;
        }
        
        //------------------------------------------------------------------------------
        if ( argScreenName == null ) _error ( "constructor : 1st argument ( Screen Name ) is null " ) ;
        if ( argAjaxUrl  == null )   _error ( "constructor : 2nd argument ( Ajax URL ) is null " ) ;
        if ( argScreenId == null ) argScreenId = 0 ;

        //==============================================================================
        // PRIVATE ATTRIBUTES
        //==============================================================================
        //--- The name of the screen
        var _sScreenName       = argScreenName ;

        //--- The URL used to send the requests
        var _sUrlBase          = argAjaxUrl ;

        //--- The ScreenContext ID in the ScreenSession
        var _iScreenId         = argScreenId ;   

        var _oInvalidField     = null ;

        //--- The ScreenFields Array ( Filled by "RegisterField()" )
        var _aScreenFields     = new Array() ; 

        //--- The ScreenViews Array ( Filled by "RegisterView()" )
        var _aScreenViews      = new Array() ;
        
        //--- The list of all the elements referenced in the screen ( "elem1,elem2,elemN" )
        var _sElements         = null ;
        
        //--- The registered screen fields serialized in XML format
        var _sSerializedFields = "" ;
        
        //==============================================================================
        // PRIVATE METHODS 
        //==============================================================================
        
        function _buildElementsList()
        {
                var map = new Map();
                for ( var i = 0 ; i < _aScreenFields.length ; i++ )
                {
                        oScreenField = _aScreenFields[i] ;
                        if ( oScreenField != null )
                        {
                                //--- If the field is mapped to a context element 
                                if ( oScreenField.sXmlTag != null )
                                {
                                        //--- Store the element name as a map key 
                                        map.put(oScreenField.sXmlTag, true); 
                                }
                        }               
                }
                _sElements = map.keysString();
        }
                
        //------------------------------------------------------------------------------
        // Serialize the given ScreenField object (in XML format) 
        //------------------------------------------------------------------------------
        function _serializeScreenField ( oScreenField, oXmlTags )
        {
                var oField = oScreenField.oField ;
                if ( oField == null )
                {
                        _error("_serializeField : ScreenField '" + oScreenField.sId + "' : oField attribute is null !" );
                }
                else
                {
                        //--- If field marked as "DO NOT SEND TO SERVER" ( Receive only ) => no serialization
                        if ( oField.bDoNotSend ) return ;
                        
                        var sFieldValue = null ;
                        if ( oField.getValue )
                        {
                                sFieldValue = oField.getValue() ;
                        }
                        else
                        {
                                sFieldValue = oField.value ;
                        }
                        if ( oField.isLongText == true )
                        {
                                //--- Long Text field => add the value as a child tag ( not as an attribute )
                                oXmlTags.addChildTag(oScreenField.sXmlTag, oScreenField.sXmlAttr, sFieldValue );
                        }
                        else
                        {
                                //--- Classical field => add the value as an attribute
                                oXmlTags.addField(oScreenField.sXmlTag, oScreenField.sXmlAttr, sFieldValue );
                        }
                }
        }
        
        //------------------------------------------------------------------------------
        // Serialize all the registered fields (in XML format) 
        // or only the fields associated with the given element name (if arg set )
        //------------------------------------------------------------------------------
        function _serializeFields ( argElementName )
        {
                //_trace("_serializeFields()");

                var oXmlTags = new XmlTags();
                var oScreenField = null ;
                var oField = null ;
                var sFieldValue = null ;

                //--- For each field registered in this screen 
                for ( var i = 0 ; i < _aScreenFields.length ; i++ )
                {
                        oScreenField = _aScreenFields[i] ;
                        if ( oScreenField == null )
                        {
                                _error("_serializeFields() : ScreenField ["+i+"] is null ! " );
                        }
                        else
                        {
                                //--- If the field is mapped to an XML attributue 
                                if (  oScreenField.sXmlTag != null && oScreenField.sXmlAttr != null )
                                {
                                        if ( argElementName != null )
                                        {
                                                if ( argElementName == oScreenField.sXmlTag )
                                                {
                                                        _serializeScreenField ( oScreenField, oXmlTags );
                                                }
                                        }
                                        else
                                        {
                                                _serializeScreenField ( oScreenField, oXmlTags );
                                        }
                                }
                        }
                }
                return oXmlTags.getXmlTags() ;
        }
        //------------------------------------------------------------------------------
        // Populate all the registered fields from the response object
        //------------------------------------------------------------------------------
        function _populateFields ( response )
        {
                //_trace("_populateFields(response) " );
                //--- If no data in the response => nothing to do
                if ( response.dataVoid() ) return ;
                
                var oScreenField = null ;
                var oField = null ;
                var sFieldValue = null ;
                
                //--- For each field registered in this screen 
                for ( var i = 0 ; i < _aScreenFields.length ; i++ )
                {
                        oScreenField = _aScreenFields[i] ;
                        if ( oScreenField == null )
                        {
                                _error("_populateFields() : ScreenField ["+i+"] is null ! " );
                        }
                        else
                        {
                                //--- If the field is mapped to an XML attributue 
                                if (  oScreenField.sXmlTag != null && oScreenField.sXmlAttr != null )
                                {
                                        oField = oScreenField.oField ;
                                        if ( oField != null )
                                        {
                                                //--- Search the field value in the response
                                                if ( oField.isLongText )
                                                {
                                                        //--- Get the value from a CHILD TAG
                                                        sFieldValue = response.getDataFieldValue ( oScreenField.sXmlTag, oScreenField.sXmlAttr, true ) ;
                                                }
                                                else
                                                {
                                                        //--- Get the value from an ATTRIBUTE
                                                        sFieldValue = response.getDataFieldValue ( oScreenField.sXmlTag, oScreenField.sXmlAttr, false ) ;
                                                }
                                                if ( sFieldValue != null )
                                                {
                                                        if ( oField.setValue ) 
                                                        {
                                                                oField.setValue(sFieldValue) ;
                                                        }
                                                        else
                                                        {
                                                                oField.value = sFieldValue ;
                                                        }
                                                }
                                                // else : the field is not in the response => no change on the screen
                                        }
                                        else
                                        {
                                                _error("_populateFields() : Field ["+i+"] is null ! " );
                                        }
                                }
                        }
                }
        }
        //------------------------------------------------------------------------------
        // Populate all the registered view from the response object
        //------------------------------------------------------------------------------
        function _populateViews ( response )
        {
                //_trace("_populateFields(response) " );                
                if ( response.hasView() == false ) return ;
                
                var oScreenView = null ;
                var oContainer  = null ;
                
                //--- For each view registered in this screen 
                for ( var i = 0 ; i < _aScreenViews.length ; i++ )
                {
                        oScreenView = _aScreenViews[i] ;
                        if ( oScreenView == null )
                        {
                                _error("_populateViews() : ScreenViews ["+i+"] is null ! " );
                        }
                        else
                        {
                                //--- If the field is mapped to a response view tag 
                                if (  oScreenView.getName() != null )
                                {
                                        oContainer = oScreenView.getContainer();
                                        if ( oContainer == null )
                                        {
                                                _error("_populateViews() : Container ["+i+"] is null ! Container id = " + oScreenView.getContainerId() );
                                        }
                                        else
                                        {
                                                sViewContent = response.getViewContent ( oScreenView.getName() ) ;
                                                /*** v 1.1.0
                                                if ( sViewContent != null ) 
                                                {
                                                        //--- Set the view in the container 
                                                        oScreenView.setContent(sViewContent);
                                                        //oContainer.innerHTML = sViewContent  ;
                                                        //--- If the container has a "onpopulate" event script => call it
                                                        var sScript = oContainer.onpopulate ;
                                                        if ( sScript != null )
                                                        {
                                                                eval ( sScript ) ;
                                                        }
                                                }
                                                ***/
                                                if ( sViewContent != null ) // v 1.1.0
                                                {
                                                        fwkShowViewContent( oContainer, sViewContent ); // v 1.1.0
                                                }                                               
                                            // else // v 1.1.0.a
                                            // { // v 1.1.0.a
                                                        //fwkShowViewContent(pContainer, ""); // v 1.1.0
                                                        //fwkShowViewContent(oContainer, ""); // v 1.1.0.a
                                            // } // v 1.1.0.a
                                                
                                        }
                                }
                        }
                }
        }
        
        //==============================================================================
        // PUBLIC METHODS 
        //==============================================================================
        this.setTrace = function ( p ) 
        {
                _bTrace = p ;
        }
        //------------------------------------------------------------------------------
        this.getScreenName = function()
        {
                return _sScreenName ;
        }
        //------------------------------------------------------------------------------
        this.getScreenId = function()
        {
                return _iScreenId ;
        }
        //------------------------------------------------------------------------------
        this.getRequestURL = function() 
        {
                return _sUrlBase ;
        }
        //------------------------------------------------------------------------------
        this.getElementsString = function() 
        {
                if ( _sElements == null )
                {
                        //--- Build the elements list
                        _buildElementsList();
                }       
                return _sElements ;
        }
        //------------------------------------------------------------------------------
        this.getViews = function() 
        {
                return _aScreenViews ;
        }
        
        //------------------------------------------------------------------------------
        this.ScreenToXml = function( argElementName )
        {
                //_trace ( "ScreenToXml()" );
                var sRet = null ;
        if ( _aScreenFields.length > 0 ) 
        {
                sRet = _serializeFields( argElementName );
        }
                return sRet ;           
        }

        //------------------------------------------------------------------------------
        this.XmlToScreen = function(response)
        {
                //_trace ( "XmlToScreen()" );
                if ( response.dataNotFound() )
                {
                        //_trace("Data not found.");
                }
                else
                {
                        //--- Populate FIELDS and VIEWS 
                if ( _aScreenFields.length > 0 ) 
                {
                        _populateFields(response);
                }
                if ( _aScreenViews.length > 0 ) 
                {
                        _populateViews(response);
                }
                }               
        }

        //------------------------------------------------------------------------------
        this.RegisterView = function(sContainerId, sScreenZone, sXmlTag, sRenderer )
        {
                if ( sContainerId == null ) 
                {
                        _error("RegisterView : no container id !");
                        return null ;
                }
                var oContainer = null ;
                try {
                        oContainer = document.getElementById(sContainerId);
                        if ( oContainer )
                        {
                                var oScreenView = new ScreenView(sContainerId, oContainer, sScreenZone, sXmlTag, sRenderer);
                        _aScreenViews.push( oScreenView );
                        }
                        else
                        {
                                _error("RegisterView : Container with id " + sContainerId + " not found ! " ) ;
                        }
                } catch ( e ) {
                        _error ( "Exception in RegisterView()! \n" + e.message ) ;
                }
        return oContainer ;
        }
        
        //------------------------------------------------------------------------------
        this.RegisterField = function(sFieldId, sScreenZone, sXmlTag, sXmlAttr )
        {
                // _trace("RegisterField(" + sFieldId +"," + sScreenZone + "," + sXmlTag + "," + sXmlAttr + ")...");
                if ( sFieldId == null ) 
                {
                        _error("RegisterField : no field id !");
                        return null ;
                }
                var oField = null ;
                try {
                        oField = document.getElementById(sFieldId);
                        if ( oField )
                        {
                                var oScreenField = new ScreenField(sFieldId, oField, sScreenZone, sXmlTag, sXmlAttr);
                        _aScreenFields.push( oScreenField );
                        //--- Is there a picto for the field ?
                                var oFieldPicto = document.getElementById(sFieldId+"_picto");
                                if ( oFieldPicto )
                                {
                                        oField.oPicto = oFieldPicto ;
                                        oField.setDisabled = fwkFieldSetDisabled ;
                                }
                        }
                        else
                        {
                                _error("RegisterField : Object with id " + sFieldId + " not found ! " ) ;
                        }
                } catch ( e ) {
                        _error ( "Exception in RegisterField()! \n" + e.message ) ;
                }
        return oField ;
        }
        //------------------------------------------------------------------------------
        this.RegisterFieldDate = function(sId, sScreenZone, sXmlTag, sXmlAttr, sFormat )
        {
                //_trace("RegisterFieldDate(" + sId +"," + sScreenZone + "," + sXmlTag + "," + sXmlAttr + ")...");
                try {                   
                        var obj = this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
                        if ( obj )
                        {
                                obj.getValue  = fwkFieldDateGetValue ;
                                obj.setValue  = fwkFieldDateSetValue ;
                                obj.format    = sFormat ;
                                obj.dateValue = new SimpleDate(null, sFormat);
                        }
                }
                catch (ex) {
                        _error ( "Exception in RegisterFieldDate : \n" + ex.message ) ;
                }
        }
        //------------------------------------------------------------------------------
        this.RegisterHidden = function(sId, sScreenZone, sXmlTag, sXmlAttr )
        {
                this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
        }
        //------------------------------------------------------------------------------
        this.RegisterComboBox = function(sId, sScreenZone, sXmlTag, sXmlAttr )
        {
                this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
        }
        //------------------------------------------------------------------------------
        this.RegisterListBox = function(sId, sScreenZone, sXmlTag, sXmlAttr )
        {
                this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
        }
        //------------------------------------------------------------------------------
        this.RegisterCheckBox = function(sId, sScreenZone, sXmlTag, sXmlAttr, sValOn, sValOff )
        {
                //_trace("RegisterCheckBox(" + sId +"," + sScreenZone + "," + sXmlTag + "," + sXmlAttr + ")...");
                try {                   
                        var obj = this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
                        if ( obj )
                        {
                                obj.valueChecked   = sValOn ;
                                obj.valueUnchecked = sValOff ;
                                obj.getValue = fwkCheckboxGetValue ;
                                obj.setValue = fwkCheckboxSetValue ;
                        }
                }
                catch (ex) {
                        _error ( "Exception in RegisterCheckBox : \n" + ex.message ) ;
                }
        }
        //------------------------------------------------------------------------------
        this.RegisterRadioGroup = function(sId, sScreenZone, sXmlTag, sXmlAttr, aRadioIds )
        {
                //_trace("RegisterRadioGroup(" + sId +"," + sScreenZone + "," + sXmlTag + "," + sXmlAttr + "," + aRadioIds + ")...");
                try {                   
                        var obj = this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
                        if ( obj )
                        {
                                //--- Build the "Radio" objects array 
                                var aRadios = new Array();
                                var oRadio = null ;
                                var iRadio = 0 ;
                                for ( var i = 0 ; i < aRadioIds.length ; i++ )
                                {
                                        oRadio = document.getElementById( aRadioIds[i] ) ;
                                        if ( oRadio != null )
                                        {
                                                aRadios[iRadio++] = oRadio ;
                                        }
                                        else
                                        {
                                                _error ( "RegisterRadioGroup() : Radio object not found !  id = " + aRadioIds[i] );
                                        }
                                }
                                obj.aRadios = aRadios ;
                                //--- Set new methods 
                                obj.getValue = fwkRadioGroupGetValue ;
                                obj.setValue = fwkRadioGroupSetValue ;                  
                                obj.setDisabled = fwkRadioGroupSetDisabled ;
                                obj.isRadioGroup = true ;
                        }
                }
                catch (ex) {
                        _error ( "Exception in RegisterRadioGroup : \n" + ex.message ) ;
                }
        }
        //------------------------------------------------------------------------------
        this.RegisterTextArea = function(sId, sScreenZone, sXmlTag, sXmlAttr )
        {
                try {                   
                        var obj = this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
                        if ( obj )
                        {
                                obj.isLongText = true ;
                        }
                }
                catch (ex) {
                        _error ( "Exception in RegisterTextArea : \n" + ex.message ) ;
                }
        }
        //------------------------------------------------------------------------------
        this.RegisterRichTextEditor = function(sId, sScreenZone, sXmlTag, sXmlAttr )
        {
                try {                   
                        var obj = this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
                        if ( obj )
                        {
                                obj.getValue  = fwkRTEGetValue ;
                                obj.setValue  = fwkRTESetValue ;
                                obj.isLongText = true ;
                                obj.isRichTextEditor = true ;
                        }
                }
                catch (ex) {
                        _error ( "Exception in RegisterRichTextEditor : \n" + ex.message ) ;
                }
        }
        //------------------------------------------------------------------------------
        this.RegisterHtmlViewer = function(sId, sScreenZone, sXmlTag, sXmlAttr )
        {
                try {                   
                        var obj = this.RegisterField (sId, sScreenZone, sXmlTag, sXmlAttr ) ;
                        if ( obj )
                        {
                                //obj.getValue  = xxxx ; // unused
                                obj.setValue  = fwkHtmlViewerSetValue ;
                                obj.isLongText = true ;
                                obj.bDoNotSend = true ;
                                obj.isHtmlViewer = true ;
                        }
                }
                catch (ex) {
                        _error ( "Exception in RegisterHtmlViewer : \n" + ex.message ) ;
                }
        }
                        
        //------------------------------------------------------------------------------
        // Clear a specific field passed by reference (object)
        //------------------------------------------------------------------------------
        this.clearField = function ( oField ) // RET : void 
        {
                //_trace ( "Screen.clearField( nodeName=" + oField.nodeName + " id=" + oField.id + ")");
                var sType = oField.type ;
                if ( sType != null )
                {
                        switch ( sType )
                        {
                                case "text" :
                                case "file" : 
                                case "password" : 
                                case "textarea" : 
                                        oField.value = "" ;
                                        /**
                                        // fwkResetFieldErrorStatus(oField); #TODO ????
                                        try {
                                                // Option par défaut (si elle existe)
                                                if ( oField.fwkDefaultValue != null ) // Par valeur
                                                {
                                                        oField.value = oField.fwkDefaultValue ;
                                                }
                                        } catch ( ex ) { 
                                                oField.value = "" ;
                                        } 
                                        **/
                                        break ;
                                                
                                case "select-one" : 
                                case "select-multiple" :
                                        oField.selectedIndex = -1 ; // Aucune ligne sélectionnée (OK / IE & Firefox)
                                        /**
                                        try {
                                                // Option par défaut (si elle existe)
                                                if ( oField.fwkDefaultValue != null )      // Par valeur
                                                {
                                                        oField.value = oField.fwkDefaultValue ;
                                                }
                                                else if ( oField.fwkDefaultIndex != null ) // Par index
                                                {
                                                        oField.selectedIndex = oField.fwkDefaultIndex ;
                                                }
                                        } catch ( ex ) { 
                                                oField.selectedIndex = -1 ; 
                                        } 
                                        **/
                                        break ;
        
                                case "checkbox" : 
                                case "radio" :
                                        oField.checked = false ;
                                        break ;
                        }
                }               
                else // NO oField.type 
                {
                        if ( oField.isRichTextEditor == true ) // Rich Text Editor                      
                        {
                                //_trace ( "Screen.clearField( nodeName=" + oField.nodeName + " id=" + oField.id + ") : CLEAR RTE ");                   
                                fwkRTEClearText(oField);                                
                        }
                        else if ( oField.isHtmlViewer == true ) // HtmlViewer ( DIV )
                        {
                                //_trace ( "Screen.clearField( nodeName=" + oField.nodeName + " id=" + oField.id + ") : CLEAR DIV");                    
                                oField.innerHTML = "" ; // Clear the DIV content
                        }
                        else if ( oField.isRadioGroup == true ) // RadioGroup widget ( DIV )
                        {
                                var elements = oField.getElementsByTagName("input") ; 
                                if ( elements != null )
                                {
                                        for ( var i=0 ; i < elements.length ; i++ )
                                        {
                                                //_trace ( "element["+i+"] : type = " + elements[i].type );
                                                if ( elements[i].type == "radio" )
                                                {
                                                        elements[i].checked = false  ;                                  
                                                }
                                        }                       
                                }
                        }
                }
        }
        //------------------------------------------------------------------------------
        // Enable / Disable a field
        //------------------------------------------------------------------------------
        this.setFieldDisabled = function ( oField, bFlag ) // RET : void 
        {
                if ( oField.setDisabled ) 
                {
                        //--- Specific disabled function for this field
                        oField.setDisabled(bFlag) ;
                }
                else
                {
                        oField.disabled = bFlag ;
                        //fwkSetFieldButtonDisabled(sId, true);
                }
        }
        //------------------------------------------------------------------------------

        //------------------------------------------------------------------------------
        this.clearViews = function ( sZone ) // RET : void 
        {
                var oScreenView = null ;
                for ( var i = 0 ; i < _aScreenViews.length ; i++ )
                {
                        oScreenView = _aScreenViews[i] ;
                        if ( oScreenView != null )
                        {
                                oScreenView.clear(sZone);
                        }
                        else
                        {
                                _error("clearViews() : View ["+i+"] is null ! " );
                        }
                }       
        }
        //------------------------------------------------------------------------------
        // Clear the entire screen or a specific zone 
        // sZone arg can be null 
        this.clear = function ( sZone ) // RET : void 
        {
                //_trace("Clear() : sZone = " + sZone );
                var oScreenField = null ;
                var oField = null ;

                //--- For each field registered in this screen 
                for ( var i = 0 ; i < _aScreenFields.length ; i++ )
                {
                        oScreenField = _aScreenFields[i] ;
                        if ( oScreenField == null )
                        {
                                _error("clear() : ScreenField ["+i+"] is null ! " );
                        }
                        else
                        {
                                oField = oScreenField.oField ;
                                if ( oField == null )
                                {
                                        _error("clear() : Field ["+i+"] is null ! " );
                                }
                                else
                                {
                                        if ( sZone == null )
                                        {
                                                //_trace("Clear() : field " + i + " - field.type = " + oField.type );
                                                this.clearField(oField);
                                        }
                                        else 
                                        {
                                                if ( oScreenField.sZone == sZone )
                                                {
                                                        this.clearField(oField);
                                                }
                                        }
                                }                       
                        }
                }       
                this.clearViews(sZone);
        }
        //------------------------------------------------------------------------------
        // Enable the entire screen or a specific zone 
        // sZone arg can be null 
        //------------------------------------------------------------------------------
        this.enable = function ( sZone ) // RET : void 
        {
                this.setDisabled ( false, sZone ) // RET : void                 
        }
        this.disable = function ( sZone ) // RET : void 
        {
                this.setDisabled ( true, sZone ) // RET : void          
        }
        this.setDisabled = function ( bFlagDisabled, sZone ) // RET : void 
        {
                var oScreenField = null ;
                var oField = null ;

                //--- For each field registered in this screen 
                for ( var i = 0 ; i < _aScreenFields.length ; i++ )
                {
                        oScreenField = _aScreenFields[i] ;
                        if ( oScreenField == null )
                        {
                                _error("setDisabled() : ScreenField ["+i+"] is null ! " );
                        }
                        else
                        {
                                oField = oScreenField.oField ;
                                if ( oField == null )
                                {
                                        _error("setDisabled() : Field ["+i+"] is null ! " );
                                }
                                else
                                {
                                        if ( sZone == null )
                                        {
                                                this.setFieldDisabled(oField, bFlagDisabled );
                                        }
                                        else 
                                        {
                                                if ( oScreenField.sZone == sZone )
                                                {
                                                        this.setFieldDisabled(oField, bFlagDisabled );
                                                }
                                        }
                                }                       
                        }
                }       
        }
                
        //------------------------------------------------------------------------------
        // METHODE : Desc
        //------------------------------------------------------------------------------
        this.desc = function()
        {
                alert ( "SCREEN OBJECT : \n" +
                                "\n . Screen-Name = " + _sScreenName + 
                                "\n . Context Id = " + _iScreenId +
                                "\n . UrlBase = " + _sUrlBase + 
                                "\n . Elements : " + this.getElementsString() +
                                "\n . " + _aScreenFields.length + " field(s) " +
                                "" );
        }

        //------------------------------------------------------------------------------
        //------------------------------------------------------------------------------
        //------------------------------------------------------------------------------
/***
        this.OnLoad = function () // RET : void
        {
                this.New();
                this.printMessage();
        }
        //------------------------------------------------------------------------------
        this.Exit = function()
        {
                //--- On essaye de fermer l'écran
                try {
                        this.close();
                }
                catch (e) {}

                //--- Si l'écran n'a pas été fermé on réinitialise l'écran
                this.New();
                this.printMessage();
        }
        //------------------------------------------------------------------------------
        this.close = function() // TODO ???
        {
                //--- Ecran popup
                if ( _iScreenId > 0 )
                {
                        //--- On sort de l'écran
                        window.close();
                }
                //--- Premier champ de l'écran
                else 
                {
                        try
                        {
                                //--- On ouvre la page d'accueil
                                document.location.href = PageAccueil; // TODO ???
                        } catch (e) {}
                }
        }
        //------------------------------------------------------------------------------
***/
        //==============================================================================
        //  GESTION DES CHAMPS ( KeyFields et DataFields ) : Disable / Clear / Check
        //==============================================================================

        //------------------------------------------------------------------------------
        // Check a specific field
        //------------------------------------------------------------------------------
        this.CheckField = function ( oField ) // RET : boolean : true = OK / false = NOK 
        {
                //--- Champ NOT NULL -------------------------------------------------------
                if ( oField.getAttribute("fwkNotNull") )
                {
                        // _trace ( "Check field ( id = " +oField.id+ " ) : attribute fwkNotNull found." ) ;
                        switch ( oField.getAttribute("type") )
                        {
                                case "text" :       // Tag "input type=text "
                                case "file" :
                                case "password" :
                                case "textarea" :   // Tag "textarea "
                                case "select-one" : // Tag "select"
                                // case "checkbox" :  // Not Null n'a pas de sens pour une "Check Box"
                                // case "radio" :     // Not Null n'a pas de sens pour un  "Radio Button"
                                        if ( oField.value == null || oField.value == "" ) 
                                        {
                                                _oInvalidField = oField ;
                                                var memoColor = oField.style.backgroundColor ;
                                                oField.style.backgroundColor = 'orange' ;
                                                _error ( "The field "+oField.name+ " ( id = " +oField.id+ " ) is required " );
                                                oField.style.backgroundColor = memoColor ;
                                                return false ;
                                        }
                                        break ;
                        }
                }
                //--- Champ dans l'état VALEUR INCORRECTE ---------------------------------- 
                if ( fwkIsFieldOnError(oField) || fwkIsFieldOnShallowCheckingError(oField) )
                {
                        _oInvalidField = oField ;
                        //_trace ( "There is an invalid field (at least) !" );
                        return false ;
                }
                return true ;
        }


        //------------------------------------------------------------------------------
        // Fonction de vérification de l'ensemble des champs
        // ( La sortie du champ éventuellement en cours de saisie est forcée 
        // au niveau de la gestion des touches de fonctions )
        //------------------------------------------------------------------------------
        this.CheckAllFields = function () // RET : boolean : true = OK / false = NOK
        {
                for ( var i = 0 ; i < _aScreenFields.length ; i++ )
                {
                        if ( this.CheckField(_aScreenFields[i]) == false ) return false ;
                }
                //--- Here all the fields are OK
                _oInvalidField = null ;
                return true ; 
        }

        //------------------------------------------------------------------------------
        function _getFieldParamValue ( oScreenField )
        {
                var oField = oScreenField.oField ;
                if ( oField == null )
                {
                        _error("_setParamValue : ScreenField '" + oScreenField.sId + "' : oField attribute is null !" );
                        return null ;
                }
                else
                {
                        //--- If field marked as "DO NOT SEND TO SERVER" ( Receive only ) => do not use as parameter
                        if ( oField.bDoNotSend ) return null ;
                        
                        //--- Long Text field : cannot be send as a parameter
                        if ( oField.isLongText == true ) return null ;

                        //--- Classical field => use the value as a parameter if not void
                        var sFieldValue = null ;
                        if ( oField.getValue )
                        {
                                sFieldValue = oField.getValue() ;
                        }
                        else
                        {
                                sFieldValue = oField.value ;
                        }
                        if ( sFieldValue == "" ) return null ;
                        return sFieldValue ;
                }
        }
        //------------------------------------------------------------------------------
        this.setParametersFromFields = function ( argParamMap, argElementName ) // v 1.1.0
        {
                if ( argParamMap == null ) 
                {
                        _error("setParametersFromFields : argParamMap is null");
                        return ;
                }
                //--- For each field registered in this screen 
                for ( var i = 0 ; i < _aScreenFields.length ; i++ )
                {
                        oScreenField = _aScreenFields[i] ;
                        if ( oScreenField != null )
                        {
                                //--- If the field is mapped to an XML attributue 
                                if (  oScreenField.sXmlTag != null && oScreenField.sXmlAttr != null )
                                {
                                        if ( argElementName != null )
                                        {
                                                if ( argElementName == oScreenField.sXmlTag )
                                                {
                                                        var sValue = _getFieldParamValue ( oScreenField );
                                                        if ( sValue != null ) argParamMap.put(oScreenField.sXmlAttr, sValue) ;
                                                }
                                        }
                                        else
                                        {
                                                var sValue = _getFieldParamValue ( oScreenField );
                                                if ( sValue != null ) argParamMap.put(oScreenField.sXmlAttr, sValue) ;
                                        }
                                }
                        }
                }
        }
        
        //==============================================================================
        //  ACTIONS UTILISATEUR 
        //==============================================================================

        //------------------------------------------------------------------------------
        // Triggers : A SURCHARGER SI NECESSAIRE
        //------------------------------------------------------------------------------
        this.beforeSelect = function () { return true ; }
        this.afterSelect  = function () { return ; }
        this.beforeUpdate = function () { return true ; }
        this.afterUpdate  = function () { return ; }
        this.beforeInsert = function () { return true ; }
        this.afterInsert  = function () { return ; }
        this.beforeDelete = function () { return true ; }
        this.afterDelete  = function () { return ; }

}