[Pas2js] WebForm Template issue

Michael Van Canneyt michael at freepascal.org
Tue Apr 3 08:11:14 CEST 2018



On Mon, 2 Apr 2018, warleyalex via Pas2js wrote:

> When you create a pas2js web-browser based project, the wizard creates the
> main project.lpr file with a start main HTML page. Now, the idea is create
> fully functional project with multiple "WebForms". 
>
> Assuming "WebForm" is basically a lazarus "form unit". However, it should
> also have an associated HTML page! you can use F12 to switch between the
> code editor and form designer for the form of the associated Unit.
> 
> When I click File -> New WebForm, to add a second form (Form2) to the
> project. The form template generates Form2 associated Unit (Unit2) and add
> "Unit2" to the project uses clause. In addiction, the form template "should"
> also create an associate HTML page "Unit2.html"
>
> Unit1.pas + Unit1.lfm + Unit1.html => for the main form
> Unit2.pas + Unit2.lfm + Unit2.html => for the second form
>
> So, the idea is the same easy-to-use centralized place for add forms into
> the current project. You go to
> File -> New... -> TWebForm to add forms to the active project.
>
> I have made some changes into the custom form project (to mimic the webform
> template), using the following code. It successfully creates and register
> the form unit to the project, but unfortunately I couldn't find a way to
> "create and add the associated HTML file" when you add the webform, the
> webform template should create this HTML file. 
>
> Anyone can shed some lights on this?

If you want to do this, you need to explicitly add a new file to the project. 
The file descriptor describes 1 file with associated .lfm file, no more.

So if you want to create a second file, you must add it from your code.
You can use the lazarus project interface for it:
lazideintf.pas, TLazIDEInterface.DoNewFile or DoNewEditorFile.

But please make this optional. I suspect that for most cases you will not
need the HTML file, and if you do, I think the html file will already exist,
since it will have been supplied by the web-designer.

So I would introduce 'New webform' and 'New webform with associated HTML'.

Michael.


More information about the Pas2js mailing list