Miscellaneous issues

Last Updated: 9/12/2007



Sections above here:
Home  »  Development  »  Custom Components

Sections below here:

    Topics in this section:
    Custom Component Development
    Developing components in Delphi
    Miscellaneous issues
    Third Party Program

    Search Documentation:

    Templates

    When a form has a template, then it is valid to not have a tag for one or more controls of the form. The missing controls just won't get rendered.

    An IWForm renders all its controls by calling RenderHTML(), before the HTML template is processed and applied. The problem is now, that if a control issues JavaScript (in RenderHTML via AddToInitProc() for example), which relies on the fact that the control exists, this code will of course fail (throw an exception) under the condition described above.

    To avoid these exceptions we recommend to do something like this:

    example from IWTreeview.RenderHTML():

    ...
    //This add every item via JavaScript to the TreeView
    LScript := iif(FContext.WebApplication.IsPartialUpdate, 'window.parent.')
    + HTMLName + 'IWCL.Items = ' + EOL + BuildAddition(nil) + ';'
    + EOL
    + iif(FContext.WebApplication.IsPartialUpdate, 'window.parent.')
    + 'InitTreeView('+
    iif(FContext.WebApplication.IsPartialUpdate, 'window.parent.') +
    HTMLName + 'IWCL, "' + HTMLName + 'Container");' + EOL;

    //if used with HTML template, the control might not be created at all
    LScript := 'if (' + HTMLName + 'IWCL){' + LScript + '}';

    ...
    FContext.AddToInitProc(LScript)
    ...

    The line in blue basically wraps the whole JavaScript in an if-block, which checks the existence of the control first. At this point (RenderHTML) there is no way to tell if the control would be handled by a possibly attached template - unfortunately.



    (C) 2002-2009 - Atozed Software Ltd.