Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Need help getting started with web app
Thu, Jun 2 2016 4:35 PMPermanent Link

TD

Advanced Data Systems, Inc.

The attached screen capture shows where I tried to create the web app using another product.  This is a web application used by fire departments to perform their equipment inspections.  I want the departments to be able to create their own inspection forms (i.e. the attached screen capture).

Each inspection ( daily, weekly, annually ) will vary in the number of items they inspect.  The first three fields will be on every inspection form but the three radio buttons, which go with the item being inspected, will vary in number.

I was thinking that the department could just enter the name of the items being inspected for a particular inspection form and then the inspection form could be automatically generated somehow.

Is this possible and if so what would be involved?

Thanks,
TD



Attachments: webapp.jpg
Fri, Jun 3 2016 7:54 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Is this possible and if so what would be involved? >>

You would do it the same way that you would do it in a desktop application:  you would dynamically create the form instance, and then create each control instance on the form (pass the form instance as the owner parameter when creating) according to the specifications in the data that you're using to determine which items to inspect.  You would use the Layout properties of each control to determine how they should be laid out on the form.

Tim Young
Elevate Software
www.elevatesoft.com
Fri, Jun 3 2016 12:34 PMPermanent Link

TD

Advanced Data Systems, Inc.

Tim Young [Elevate Software] wrote:

<< Is this possible and if so what would be involved? >>

You would do it the same way that you would do it in a desktop application:  you would dynamically create the form instance, and then create each control instance on the form (pass the form instance as the owner parameter when creating) according to the specifications in the data that you're using to determine which items to inspect.  You would use the Layout properties of each control to determine how they should be laid out on the form.

Thanks Tim.  Is there any examples in the manual on how to do this, just to get me started?

TD
Sat, Jun 4 2016 2:43 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< Thanks Tim.  Is there any examples in the manual on how to do this, just to get me started? >>

There's a small example here:

http://www.elevatesoft.com/manual?action=viewtopic&id=ewb2&topic=Creating_Showing_Forms

under "Creating a Form at Run-Time".

You can also just do something like this:

var
  MyForm: TMyForm;
begin
  MyForm:=TMyForm.Create(Application);
  MyForm.Show; // or ShowModal
end;

To create controls on the form at run-time, just create them using the Create constructor, passing the container form as the Owner parameter:

var
  MyEdit: TEdit;
begin
  MyEdit:=TEdit.Create(MyForm);
end;

If you want to parent a control to something other than the form, just set its Parent property after creating it:

var
  MyPanel: TBasicPanel;
  MyEdit: TEdit;
begin
  MyPanel:=TBasicPanel.Create(MyForm);
  MyEdit:=TEdit.Create(MyForm);
  MyEdit.Parent:=MyPanel;
end;

Of course, in order to avoid slow execution, use the BeginUpdate/EndUpdate methods to wrap the whole process:

var
  MyForm: TMyForm;
  MyPanel: TBasicPanel;
  MyEdit: TEdit;
begin
  MyForm:=TMyForm.Create(Application);
  MyForm.BeginUpdate;
  try
     MyPanel:=TBasicPanel.Create(MyForm);
     MyEdit:=TEdit.Create(MyForm);
     MyEdit.Parent:=MyPanel;
     MyForm.Show; // or ShowModal
  finally
     MyForm.EndUpdate;
  end;
end;

Setting the layout properties is simply a matter of setting them as desired after creating each control.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Jun 6 2016 4:22 AMPermanent Link

Matthew Jones

Just to add to Tim's info, based on code I've just been doing exactly
what you are wanting to do, there is a little tweek that makes things
easier. I created a basically empty form called TfrmOptionBase, and
added a public procedure:
  procedure SetOption(xOption : TObject); virtual;

and implementation:

procedure TfrmOptionBase.SetOption(xOption : TObject);
begin
   raise Exception.Create('Oops report option setOption not
overridden');
end;

Then, create your other option forms, set alignment for them to be top
left, stretch right, consume bottom, and implement the SetOption
procedure.

This way the parent form knows that the options are all based on a
particular form type, and can call the common set. Here is my checkbox
version:

procedure TfrmOptionCheck.SetOption(xOption : TObject);
var
   xReportOption : TReportOption;
begin                            
   xReportOption := TReportOption(xOption);
   chkSelection.Caption := xReportOption.Label;
   SetChecked(chkSelection, xml_X2Boolean(xReportOption.Default,
false));
end;

Each form remembers its option, which is a class that is a member of
the controller.

Anyway, I hope that helps a little.

--

Matthew Jones
Mon, Jun 6 2016 4:23 AMPermanent Link

Matthew Jones

Matthew Jones wrote:

> Then, create your other option forms, set alignment for them to be top
> left, stretch right, consume bottom, and implement the SetOption
> procedure.

Oh, I missed out "and change the form to derive from TfrmOptionBase":

TfrmOptionCheck = class(TfrmOptionBase)

--

Matthew Jones
Mon, Jun 6 2016 11:30 AMPermanent Link

TD

Advanced Data Systems, Inc.

Thanks guys for helping.  This is one area my Delphi knowledge is very weak so I need all the help I can get.  I do have one question:

Does there need to be a "form unit" already existing in the project ( i.e. File, New, Form ) that will be used as the form to be created dynamically?   Hope that makes sense.

Thanks guys, your help is greatly appreciated!
TD
Mon, Jun 6 2016 11:35 AMPermanent Link

Matthew Jones

TD wrote:

> Does there need to be a "form unit" already existing in the project (
> i.e. File, New, Form ) that will be used as the form to be created
> dynamically?

Yes. Start with your "master" form, which will display the options. On
that, add text, and a TScrollPanel. Then create a new form for each of
the option TYPES (with layout set as I described). Then for each option
you want a "control" for, create one of those types. By code is like
this:

procedure TfrmReportSelector.CreateOptions(xReport : TReportInfo);
var
   nLoop : Integer;
   xOption : TReportOption;
begin
   for nLoop := 0 to xReport.OptionList.Count - 1 do
   begin                   
       xOption := xReport.OptionList.Items[nLoop];
       case xOption.type of
       'radio':
           begin
               xOption.EditForm := TfrmOptionRadio.Create(Application);
           end;

       'boolean':
           begin
               xOption.EditForm := TfrmOptionCheck.Create(Application);
           end;

       else
           xOption.EditForm := nil;
       end;                
       if assigned(xOption.EditForm) then
       begin
           xOption.EditForm.Parent := pnlOptions;
           xOption.EditForm.SetOption(xOption);
       end;
   end;                
end;

--

Matthew Jones
Wed, Jun 8 2016 9:07 PMPermanent Link

TD

Advanced Data Systems, Inc.

Just thought I would report back at I've make some progress with this, all due to you guys help!

TD
Thu, Jun 9 2016 8:39 AMPermanent Link

Mark Brooks

Slikware

Avatar

For what it's worth, most of my recent work with EWB2 has involved the creation of web apps that interact with one or more REST APIs. It's an incredible tool for this kind of work, especially with the JSON parsing built into the latest release. Let me know if you have any specific issues because I may have come across them before myself. Best of luck.
Image