WebHub Object Pascal Components

Bug-fix on app exit v3.220
An issue has been fixed for apps exiting where (a) the hub was never running and (b) there were no page requests made.
Minor fix to logging v3.220
If you were compiling with -DCodeSite and had bounces, you might have noticed that the logs indented without outdenting, once for each bounce. That has been fixed.
TWebDataForm SetWorkKey method v3.220
TWebDataForm was fixed for the use-case of the Delphi Prefix Registry sample/demo project, where the OnSetCommand event handler needs a way to customize the working key after decrypting details from the URL.
ucHttps.pas compiles for XE7 FMX v3.220
This tpack unit can be used from within an XE7 FireMonkey mobile application for http requests using Indy.
JSON data using utf-8 charset v3.220
If you set the prologue type to JSON, the header will include utf-8 as the charset automatically now.
Source: webPrologue.pas and ucHttps.pas
ucJSONWrapper in XE7 v3.220
This method had to be changed slightly for use with XE7: TExtendedVariantType.DispInvoke
Source is in TPack
Exported HTML in UTF-8 has no BOM v3.221
Previously exported static HTML files were in UTF-8 format with a BOM.
Now the byte order mark is omitted.
New property: PageIDLower v3.221
This returns the PageID forced to lowercase. Use it in MATCH expressions and elsewhere for easier comparisons.
It is a property on the TwhPage object and on the TwhApplication. For the latter, it is for the current page being served to the current surfer.
New routine: IbAndFb_GenSQL_ResetGenerators v3.221
This generates SQL suitable for use with Interbase and Firebird. It creates a procedure that resets a generator for each table to the maximum primary key value of that table.
Source: ucIBObjCodeGen.pas in TPack
New routine: Firebird_GenPAS_RecordStruct v3.221
This generates a Delphi record structure for each table in a Firebird SQL database.
Numeric fields (for example, domain CURRENCY_D) that are NUMERIC(16,2) are considered Delphi Currency fields.
Source: ucIBObjCodeGen.pas in TPack
New routine: IbAndFb_GenSQL_Grant_Select v3.221
This generates a Grant Select on __tablename__ to ROLE __rolename__ statement for each table.
Use this to help create a readonly role and user for a given database.
Source: ucIBObjCodeGen.pas in TPack
Sample usage: whdemo_DMIBObjCodeGen.pas in WebHubDemos project.
Enhancements: TwhdbListBox v3.221
Set CacheUntilRefresh to True to have the component cache the list of choices until the next time the app refreshes.
Set UsingJQuery to True if you are using the JQuery JavaScript library on the WebHub page where you execute the TwhdbListBox.
When both CacheUntilRefresh and UsingJQuery are True, an extra line of JavaScript will be generated. This will set the selection in the drop-down based on the current surfer data.
DataSource property has been deprecated. Instead, connect the DataSet: TDataSet directly to the TwhdbListBox.
Source: wdbLstBx.pas
Minor fix: TtpProjectv3.223
In the OnGUIInit event, setting Continue to False is now respected and the application will not run.
Built-in site map can list export filenames v3.223
The waSiteIndex webaction is included in whsample_GoogleSitemap.pas.
New optional parameter: waSiteIndex.Execute|ShowExportFilenames
This is intended primarily for in-house use, for quick review within hybrid static/dynamic sites.
MarkTerminateASAP v3.224
This method on the WebHub connection component had not been working. This has been resolved.
Use this method (pConnection.MarkTerminateASAP; // uses webCall) when you want your custom EXE to exit after an access violation or other serious exception caught in your OnError handler.
SetCodeSiteLoggingState v3.224
There is a new global flag which controls whether the procedures in ucCodeSiteInterface.pas log something(s) or nothing.
The logging state defaults to logging everything: Notes, Info, Warnings, Errors, Exceptions and Enter/Exit Method calls.
The purpose of this new feature is so that you can compile an EXE with -DCodeSite;Log2CSL yet fine-tune when logging is active, in case you want it to be off during certain hours or outside of troubleshooting periods, or only report Exceptions.
Example: SetCodeSiteLoggingState([]); // none
Example: SetCodeSiteLoggingState([cslNote, cslError, cslException]);
See procedure TDemoExtensions.DemoAppUpdate in "D:\Projects\webhubdemos\Source\WHApps\Common\whdemo_Extensions.pas" for sample code to load the flags from an AppSetting in the application-level XML file. Putting the code into an event that runs on refresh means that you can change the flags in the XML, refresh, and have a new level of logging active.
Source: ucCodeSiteInterface.pas (incl in tpack and webhub)
Delphi XE8 support v3.225
WebHub v3.225 is the first version to support Delphi XE8, released 7-Apr-2015.
SessionLingvo v3.225
Even if zero pages have been served SessionLingvo now defaults to the ProjectLingvo. This is important when exporting static pages from a WebHub application.
New: IbAndFb_GenSQL_CreateGenerators v3.226
For each Firebird SQL table where the description for the primary key field equals "autoincrement", make an appropriate Firebird GENERATOR based on a custom naming function for the generator-name.
See whdemo_DMIBObjCodeGen.pas for usage example.
Source: ucIBObjCodeGen.pas in TPack
New: Firebird_GenPAS_ObjectStruct v3.226
For each Firebird SQL table, generated a TObject corresponding to the table structure, using published properties so that RTTI can be leveraged.
Source: ucIBObjCodeGen.pas in TPack
New: Firebird_GenPAS_FieldNameConstants v3.226
For each Firebird SQL table, generated a const corresponding to each fieldname.
Source: ucIBObjCodeGen.pas in TPack
New: Load_IBObject v3.226
Using RTTI, fill a Delphi TObject with corresponding fields from an IBOBjects TIB_Dataset.
The TObject must have published properties whose names correspond exactly to the field names.
Use this together with the output from Firebird_GenPAS_ObjectStruct which generates a PAS file with suitable TObjects for a given Firebird or Interbase database.
See whdemo_DMIBObjCodeGen.pas for usage example.
See ucDataSetRTTI.pas in TPACK for a variation that works on any Delphi TDataSet.
Source: ucIBObjRTTI.pas in TPack
New: more integration with JQGrid v3.226
The TjqGrid class has a new method, JQGrid_JavaScript, which generates the contents of a JS file (that you would probably save as a static resource), based on a datastructure build from the new "WebHub Table Defs". This will be in flux between now (April) and June 2015, most likely.
The aim is for the JQGrid integration to work with any TDataSet, whether that be ADO, FireDAC, TIBOQuery or anything else that derives from TDataSet.
JQGrid version: 4.7.1
Alert: these units have been moved into a separate svn repository so that interested WebHub customers can use the files more conveniently. Contact customer service for information and access to "manahua."
Source: manahua.whTableDefs.pas and manahua.whutil_JQGrid.pas
HTML CHECKBOX processing v3.226
Reference: p9 has relevant chart.
WebHub now works like PHP and many-but-not-all major web frameworks in terms of respecting ONLY the last form value when duplicates values for the SAME fieldname are submitted. This enables a solution to the HTML problem of checkboxes, so that WebHub can work the same as Ruby on Rails, etc., and the KEEPCKB syntax is no longer required. Furthermore, the true/false checkbox values can be customized on a field by field basis, so that you can conveniently post the needed value to a "boolean" database field that might be 1,0 or True/False or Y/N or any other pair of values.
The latest lite FORM demo shows how this works.
Source: webVars.pas
The syntax for the new usage of checkboxes is:
Y,N any pair of values can be used here, always with the TRUE state being first. Valid examples include
  • OnOff=Y,N
  • OnOff=1,0
  • OnOff=Yes,No
  • OnOff=(~mcYes~),No
  • OnOff=(~mcYes~),(~mcNo~)
  • OnOff=(~mcYesNo~)
The additional attributes were required in v3.226-v3.228. They are optional as of v3.229.
The HTML generated by INPUTCHECKBOX with OnOff specified is an INPUT type="hidden" with the Off word, followed by an INPUT type="checkbox" with the On word. Through the miracle of the (ridiculously informal) HTML specification, this leads to the desired end result when you can actually turn a checkbox OFF and find out about that, server-side.
If you put a disabled attribute into the optional html attributes for the INPUTCHECKBOX, the hidden field will also be disabled.
Parentils within additional attributes did not work in v3.226, v3.227 with classic syntax. Please use v3.228+.
Source: htWebApp.pas
For classic syntax, parentild expressions are allowed within the checkbox name and/or the additional attributes.
This feature was not working in v3.226, v3.227.
interfaces moved v3.226
Working toward having more of the interface definitions in PAS files that automatically ship with full source.
New source: wdbSSrc_intf.pas, webLink_intf.pas
proJS JavaScript content-type v3.227
Developers should use the (new) built-in prologue type proJS for dynamic JavaScript pages with WebHub.
From WHTEKO, use this with SETPROLOGUETYPE. From Delphi, use this with pWebApp.Response.SetContentType.
Source: webPrologue.pas
TwhCaptcha suitable for use with ajax pages v3.228
The syntax for TwhCaptcha has been extended slightly, to allow for use from web pages where the data is posted using JavaScript rather than a simple FORM post. There was never an issue if all data validation passed. However, if some data other than the captcha code prevented the document.location from moving forward, then the surfer would not have been able to match the captcha code unless the browser page were reloaded.
The new syntax keywords are "control+save" and "clear". Use "control+save" instead of "control" when controlling the captcha code in the use-case described above. Then use "clear" when you are ready to move the document.location and no longer require the code saved.
If you are doing a simple FORM post, without JavaScript, this is backwards-compatible; no changes are required.
New: SetCodeSiteLoggingStateFromText v3.228
This routine can be called from any Delphi program that uses the CSSend, CSSendWarning, etc. routines in the ucCodeSiteInterface.pas unit.
It lets you determine the categories of messages that you want logged, at runtime.
WebHub applications might want to set the logging level from an AppSetting, or even from surfer data.
Source: ucCodeSiteInterface.pas
MATCH against blank string v3.228
With the = operator, MATCH and NOMATCH can now be used to check against a blank string.
Example: (~NOMATCH|(~command~)=|/0/(~command~)~)
To find out whether this will change any MATCH logic in existing projects, search for regular expression =\| in your *.whteko files. It is unlikely that you were making use of the prior behavior, which basically gave a false negative in that the 'equality' always failed.
MaxPages default 10 on Input and Output panels v3.228
The default has changed from 0 to 10 for the number of pages of input and output to preserve in the tabs.
New unit: keyedList v3.229
Generics: a list with some handy functions
Source: TPack
New unit: ucDataSetRTTI v3.229
This uses RTTI to copy data from a record in any TDataSet into a Delphi object with corresponding properties that match up to the fieldnames.
See Load_Object routine
Source: TPack

The Hub

Setup installer prevents blank folders for essential paths v3.221
Previously, a clean install would leave the 2 essential paths blank in WHNetworkInfo.xml: the logging folder and the shared ipc folder.
Now those folders default to {RootForWHDataFolders}whLogs and {RootForWHDataFolders}whIPC where RootForWHDataFolders is a variable defaulting to c:\ProgramData\WebHubData\ and easily changed in the WHNetworkInfo.xml file. This can be changed after installation, using ZMAdmin.
All aspects of a WebHub deployment require read/write access to those folders. This includes the runner, the Hub service, and any custom applications.
Please use v3.222+ when installing on top of existing installations.
Please see support message
Date: Thu, 15 Jan 2015 07:44:58 GMT
Message-ID: cdp3621@WendzelNNTPdAnonymous
for workaround steps for existing installations until v3.222 is available.
Setup installer creates recommended ZM Variables v3.222
For existing installations, the WebHub Runtime Setup now modifies webhub\cv004\ZMKeybox.xml, WHCentralInfo.xml and WHNetworkInfo.xml so that each one has a variable named "RootForWHDataFolders". This variable can be optionally combined with other values within those files to specify directory locations.
Defaults ZaphodsMap env var v3.221
The default location is now C:\ProgramData\ZaphodsMap\ and this can be changed the first time the Runtime Setup is used.
Session Folder v3.221
For a clean install, the folder for *.var session files is set to {RootForWHDataFolders}whSessions where RootForWHDataFolders is a variable defaulting to C:\ProgramData\WebHubData\ and easily changed in the WHCentralInfo.xml file.
The definition of RootForWHDataFolders in WHCentralInfo.xml and WHNetworkInfo.xml is independent because ZaphodsMap variables are scoped to a single XML file. We recommend that you use the same path in both files.
Existing sites may want to adopt this convention, putting all scratch/temporary files under a single root on the disk. This could include log files, session var files, uploaded files, coverpage info files, and IPC files. All of those paths are configured in WHCentralInfo.xml and WHNetworkInfo.xml.
Remember to restart IIS, the Hub service and any custom EXEs if you change these key configuration files file.
Corrected XSD v3.221
On a new clean install, the WebHubInstallationConfig.xml file now has the correct XSD address, which is http://www.zaphodsmap.com/zmdesign/xsd/ZaphodsInstaller200605.xsd
Previously the xsd date was 200512 and that file no longer exists.
Setup: more silent v3.223
When started with the /S argument for Silent mode, the WebHub Runtime Setup does not report missing application-level XML files even if you ask it to check the validity of the XSD path for each AppID.

WebHub Runners

Default AppID supported v3.220
/scripts/runisa.dll? now leads to the default page in the default appid. Previously it set the appid to 'appvers' regardless of configuration within WHCentralInfo.
Runner: file upload folder v3.221
For a clean install, the upload folder is set to {RootForWHDataFolders}whUpload where RootForWHDataFolders is a variable defaulting to c:\ProgramData\WebHubData\ and easily changed in the WHNetworkInfo.xml file.