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.
[QUOTE]If the control has a data binding ([URL="https://support.dataaccess.com/Forums/:/Entry_item_Command.htm"]Entry_Item[/URL]) and is set to C_WebDefault, this property will be automatically set to True if the corresponding [URL="mk:@MSITStore:C:\Program%20Files%20(x86)\DataFlex%2019.1\Help\VdfClassRef.chm::/DataDictionary.htm"]DataDictionary[/URL]'s [URL="mk:@MSITStore:C:\Program%20Files%20(x86)\DataFlex%2019.1\Help\VdfClassRef.chm::/DataDictionary-Property-Field_Validate_msg.htm"]Field_Validate_msg[/URL] property is set.[/QUOTE]
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
[/code]
Compile, run it.
type anything in the login name form, and tab to exit the form.
onValidate will be fired.
Regards
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)){
[/CODE]
should be
[CODE]
if (this['pbServer' + sName] && df.toBool(this['pbServer' + sName]) && !oConf.bSkipServer){
[/CODE]
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
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
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;
};
}
[/CODE]
Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls
Thanks Michael
Appreciate it!
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
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?
Re: OnValidate being fired with pbServerOnValidate set to C_WebDefault for non data-binded controls
Just did...
[TABLE]
[TR]
[TD]HDE 6625
Hope this get some attention for next release, as it seem to be a simple fix in the java side.
Regards
[/TD]
[/TR]
[/TABLE]
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.