TWebForm TJSPromise functions

Hi Bruno,

Just saw exciting updates on 1.7. One of new features: TJSPromise functions is very interesting. I tested using load() function to create a pop-up form and it works perfectly. Now I got a question, what should we do if we would like to create form using TJSPromise function that is hosted on say a panel? Here simply copy/paste your sample code to show a new form modally:

I guess we should somewhere set form container for the form (newform.FormContainer := WebPanel1.ElementID;), right? here I tried however it did not work properly. Any tip/suggestion would be great, thanks!

newform := TForm2.Create(Self);  
  newform.Caption := 'Child form';

// load file HTML template + controls  
  await(TForm2, newform.Load());  
  
  // init control after loading  
  newform.frm2Edit.Text := WebEdit1.Text;

Did you try to create the form as
newform := TForm2.Create('id');

with id the HTML element ID of the HTML element where you want to host the form?

Hi Bruno,
I am trying to alter the sample TMSWeb_FormHosting project (supplied in the demo source code) to use the await statement. In order to embed the subform, I used the HTML id in the create as suggested above.

procedure TFrmMain.NewButtonClick;
begin
// destroy possible old form
if Assigned(frm) then
frm.Close;

// frm := TSubForm1.Create(Self); // This line does not throw an error on the await

frm := TSubForm1.Create(HostPanel.ElementID);
await(TSubForm1, frm.Load()); // The await line throws an error

{ if Assigned(frm) and (frm is TSubForm1) then
( frm as TSubForm1 ).lbTexts.Items.Assign(lbTextsMain.Items);
}
btTransferGet.Enabled := true;
btTransferSet.Enabled := true;
end;

The error is:
Duplicate component name: "WebLabel1"

Please could you help.

Are you sure you effectively use the latest version v2.0.5.0?

Am using Tms Web Core 2.0.2.3. (Delphi 11.2) Will upgrade and try again.

Thank you

The latest version v2.0.5.0 also throws the error.

The Create() overload where you use the ID of a HTML internally already calls Load, so your code tries to load twice.

Thank you! I followed the code through and saw that. I was just following the advice of the earlier post.
I have reverted to the original code.