Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    2,378

    Default OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    OnValidate is being fired for regular webForms, when there is no file.field bound to the control, and pbServerOnValidate is set to c_WebDefault.

    For regular controls, (not data-bound), if set to cWebDefault this should resolve to False, by default. The documentation does not say that explicity, but let this rule in mind by stating the opposite.
    If the control has a data binding (Entry_Item) and is set to C_WebDefault, this property will be automatically set to True if the corresponding DataDictionary's Field_Validate_msg property is set.
    This should not be happening. Waste of round-trip call. as there is nothing to validate on the server side.

    This can be reproduced in webOrderMobile.

    Change login dialog, just implementing the OnValidate method for the oLoginName webform.

    Code:
        Object oLoginName is a cWebForm
            Set psLabel to "User ID:"
            Set peLabelPosition to lpTop
            Set piMaxLength to 20
            Set piColumnIndex to 1
            Set pbShowLabel to False
            Set psPlaceHolder to "loginname"
            Set piColumnSpan to 10
    
            Function OnValidate Returns Boolean
                Boolean bRetVal
                Forward Get OnValidate to bRetVal
                Showln 'onvalidate'
                Function_Return bRetVal
            End_Function
        End_Object
    Compile, run it.
    type anything in the login name form, and tab to exit the form.
    onValidate will be fired.

    Regards
    Samuel Pizarro

  2. #2
    Join Date
    Feb 2009
    Location
    South Florida
    Posts
    3,856

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    nice catch

    bug in WebObject.js line 625. Parenthesis in wrong place

    Code:
    if(this['pbServer' + sName] && df.toBool(this['pbServer' + sName] && !oConf.bSkipServer)){
    should be

    Code:
    if (this['pbServer' + sName] && df.toBool(this['pbServer' + sName]) && !oConf.bSkipServer){
    Michael Salzlechner
    StarZen Technologies, Inc
    http.://www.starzen.com

    Development Blog
    http://www.salzlechner.com/dev

    DataFlex Package Manager (aka Nuget for DataFlex)
    http://windowsdeveloper.com/dfPackage

  3. #3
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    2,378

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    Nice catch for you!

    Wonder if we are supposed to edit this .js file manually, or if harm is going to provide a hot-fix workarround, so we dont mess with system files.

    Thanks
    Samuel Pizarro

  4. #4
    Join Date
    Feb 2009
    Location
    South Florida
    Posts
    3,856

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    editing the file wouldnt help because it isnt used except in debugging mode. you'd need a hotfix
    Michael Salzlechner
    StarZen Technologies, Inc
    http.://www.starzen.com

    Development Blog
    http://www.salzlechner.com/dev

    DataFlex Package Manager (aka Nuget for DataFlex)
    http://windowsdeveloper.com/dfPackage

  5. #5
    Join Date
    Feb 2009
    Location
    South Florida
    Posts
    3,856

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    you could try this until you get a fix from DAW

    keep in mind this is a quick try from me. seems to do the trick but again ...

    Code:
    if(df.pnDataFlexVersion == 19.1){
    df.WebObject.prototype.fireEx = function(oConf){
        var oEvent, bResult = false, bASync = false, oFunc;
        
        //df.debug('Event: ' + sName + " " + df.sys.json.stringify(aOptParams || []) + " on " + this.getLongName() + "  (Call mode: " + this._oServerActionModes[sName.toLowerCase()] + " )");
        
        sName = oConf.sEvent;
    
    
        if(!sName){
            throw new df.Error(999, "Event name missing in fireEx.", this);
        }
    
    
        if(!oConf.aParams || !(oConf.aParams instanceof Array)){
            oConf.aParams = [];
        }
        
        //  Create event object
        oEvent = new df.events.JSEvent(this, { 
            aParams : oConf.aParams,
            oConf : oConf,
            bClient : false,
            bServer : false,
            sReturnVal : null,
            aViews : oConf.aView || []
        });
        
        //  Search for & call global event listener
        if(this['psClient' + sName] && !oConf.bSkipClient){
            oFunc = this.findFunc(this['psClient' + sName]);
            if(typeof oFunc.fFunc === 'function'){
                oEvent.bClient = bResult = true;
                try{
                    if(oFunc.fFunc.call(oFunc.oEnv, oEvent) === false){
                        oEvent.stop();
                    }
                }catch (oError){
                    this.getWebApp().handleError(oError);
                }
            }else{
                this.getWebApp().handleError(new df.Error(999, "Event handler function '{{0}}' set as 'psClient{{1}}' not found.", this, [this['psClient' + sName], sName]));
            }
        }
        
        //  Search for advanced client-side handler
        if(!oEvent.bCanceled){
            if(this[sName] instanceof df.events.JSHandler){
                //  Determine if there are clients
                oEvent.bClient = bResult = (bResult || this[sName].aListeners.length > 0);
                this[sName].fire(this, oEvent);
            }
        }
        
        //  Call the server
        if(!oEvent.bCanceled){
            
            if (this['pbServer' + sName] && df.toBool(this['pbServer' + sName]) && !oConf.bSkipServer){
    
    
            // if(true){
                bResult = true;
                bASync = true;
                
                //  Perform server call
                this.serverAction(sName, oConf.aParams, null, function(oActEvent){
                    //  Set results
                    oEvent.sReturnValue = oActEvent.sReturnValue;
                    oEvent.bServer = true;
                    
                    //  Call the handler
                    if(oConf.fHandler){
                        oConf.fHandler.call(oConf.oEnv || this, oEvent);
                    }
                }, this);
            }   
        }
        
        //  Call the handler
        if(!bASync){
            if(oConf.fHandler){
                oConf.fHandler.call(oConf.oEnv || this, oEvent);
            }
        }
        
        return bResult;
    
    
    };
    }
    Michael Salzlechner
    StarZen Technologies, Inc
    http.://www.starzen.com

    Development Blog
    http://www.salzlechner.com/dev

    DataFlex Package Manager (aka Nuget for DataFlex)
    http://windowsdeveloper.com/dfPackage

  6. #6
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    2,378

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    Thanks Michael

    Appreciate it!
    Samuel Pizarro

  7. #7
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    2,378

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    Bump..

    Hi DAW,
    Have you acknowledge this to be fixed in next released ?

    Regards
    Samuel Pizarro

  8. #8
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    8,939

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    Samuel,

    Did you log this as a bug via HDE?
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

  9. #9
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    2,378

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    Just did...

    HDE 6625

    Hope this get some attention for next release, as it seem to be a simple fix in the java side.

    Regards
    Samuel Pizarro

  10. #10
    Join Date
    Feb 2009
    Location
    The Netherlands
    Posts
    3,974

    Default Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls

    The check in fireEx was indeed incorrect (thanks Michael) but WebBaseDEO should have also had a this.event("OnValidate"); call. Both fixes will be in the next rev. As I can't easily make a JS fix for a constructor lets go with the one created by Michael.
    Harm Wibier
    Data Access Europe B.V.
    http://www.dataaccess.eu/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •