I have a problem with creating a new WebForm.
I take a similar approach as created with the XDataWebApplication wizard.
To display a page, I have the "Display" class function.
In contrast to the example, I use "Application.CreateForm" instead of "TMyWebForm.CreatNew". I do this because otherwise the page (HTML Template) is not displayed.
Now the problem.
If I release a possibly existing form beforehand, nothing happens. (see Wizard example) If I don't do the "Free", it works.
Better seen here in the code:
Example 1 (XDataWebApplication Wizard)
class procedure TFViewErrorPage.Display(AErrorMessage: string);
procedure AfterCreateProc(AForm: TObject);
begin
TFViewErrorPage(AForm).lbMessage.Caption := AErrorMessage;
end;
begin
if Assigned(FViewErrorPage) then
FViewErrorPage.Free;
FViewErrorPage := TFViewErrorPage.CreateNew(@AfterCreateProc);
end;
Example 2 (my own code, not working)
class procedure TfrmError.Display( AElementId: String; AFormCloseProc: TFormCloseProc; AMessage: String = '');
procedure AfterCreate(AForm: TObject);
begin
TfrmError( AForm).FFormCloseProc := AFormCloseProc;
end;
begin
if Assigned( frmError) then
frmError.Free;
Application.CreateForm( TfrmError, AElementId, frmError, @AfterCreate);
end;
Example 3 (my own code. This works)
class procedure TfrmError.Display( AElementId: String; AFormCloseProc: TFormCloseProc; AMessage: String = '');
procedure AfterCreate(AForm: TObject);
begin
TfrmError( AForm).FFormCloseProc := AFormCloseProc;
end;
begin
// if Assigned( frmError) then
// frmError.Free;
Application.CreateForm( TfrmError, AElementId, frmError, @AfterCreate);
end;
Is it possible that the work is done so much asynchronously here that the "Free" is executed after the "Create"?
And what is the difference between "Application.CreateForm" and "TMyWebForm.CreateNew"
All pages have HTML templates. The " AElementId is "body".
Thank you
Thomas