Recent

Author Topic: Status of toolkit for ExtPascal  (Read 97521 times)

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #60 on: January 12, 2010, 09:25:49 am »
In general, I try to avoid using any LCL in a Web app, but in this case you may not have much choice.
I absolutely agree with you that avoiding any LCL should be the goal here. I would rather create some  completely new timer code than needing to use the LCL just for that purpose.

But the underlying problem is not the timer itself, but the event programming paradigm, the timer and much other stuff needs and which in fact is the basis of ObjectPascal programming, Event driven programming and doing free running application (with "asynchronous" actions) needs some stuff I did not yet find to be already done with the ExtP, ExtPascal, ExtJS trio:

 - a "Main Thread" for handling asynchronous events (supposedly easy to do by using the process main thread or by adding an additional thread)

 - an event queue for scheduling these events (The LCL does this by it's binding to the GUI framework. An example how this can be done with pure FPC code can be found in the open source MESGUI: "NonGUIApplication". The ExtPascal Web page talks about ExtPascal offering "Optional Delphi/Lazarus event handler. Did I somehow miss to enable/use this "option" ?)

 - a way to display asynchronous changes in the client's browser. I know that this is done with AJAX applications by having the JavaScript code poll the CGI-Application for (a notification of) changes, and to avoid too much traffic, the CGI application leaves such polling request "hanging" for a period shorter than the normal HTTP timeout, unless a change in fact is detected. (I don't know if something like this even is provided by ExtJS.In that case I'm out of the game here, being a Java illiterate).

The extPascal "online Samles" ( http://extpascal.call.inf.br/cgi-bin/extpascalsamples.cgi/MessageBoxes ) demonstrate a "Progress Dialog". Provided this is not just a fakel, asynchronous changes Server->Browser seem to have been implemented.

What do you think ?
-Michael
« Last Edit: January 12, 2010, 04:25:23 pm by mschnell »

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #61 on: January 12, 2010, 09:40:42 am »
VCL/LCL TCheckBox does not have an ItemIndex property so I'm not sure what you're referring to.
Sorry, I was typing faster than thinking.

I was trying to report two differnt problems:

(1) TExtCheckbox: here I get an event when the state is toggled by the client, but the "Checked" property always stays the same

(2) TExtFormRadioGroup: here I don't find a propty like "ItemIndex" that would report the state the user selected to the application. When I decide to digg deeper into this kind of "HTML-GUI" framework, I will see if I can do anything about the display problem with TExtFormRadioGroup, but if same is on the Java site, I will not be able to improve it.

Thanks,
-Michael
« Last Edit: January 12, 2010, 09:43:47 am by mschnell »

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #62 on: January 12, 2010, 09:47:48 am »
This is Ext JS, not VCL/LCL. Use the appropriate properties.
Of course. But seemingly the goal of EXTP is to maked ExtPascal (and thus ExtJS) more usable for educated Delphi/Lazarus/VCL/LCL users, by allowing them to use their beloved IDE to design a "Browser-GUI". So providing as much the same properties as possible would be nice. This said: supposedly modifying ext.pas might be not a good idea, but I see that as an application created with ExtP directly uses ext.pas, it would need for not-trivial enhancements for ExtP to offer this additional comfort (by automatically modifying ext.pas or by providing an interface unit that is to be used in the unit's "uses" instead of extp (and maybe more ExtPascal-units).

After some coding.....
This has been a lot less difficult than I thought:

I created a unit Extp:
Code: [Select]
unit extp;
{$mode objfpc}{$H+}
interface
uses
  Ext;
type
  TExtPanel  = class(Ext.TExtPanel);
  TExtWindow = class(Ext.TExtWindow);

  { TExtButton }
  TExtButton = class(Ext.TExtButton)
   private
     function GetCaption: String;
     procedure SetCaption(const AValue: String);
   public
    property Caption: String read GetCaption write SetCaption;
  end;

implementation
{ TExtButton }
function TExtButton.GetCaption: String;
begin
  Result := inherited Text;
end;

procedure TExtButton.SetCaption(const AValue: String);
begin
  inherited Text := AValue;
end;

end.

Now in the "GUI" unit of the application, in the "UseRuntime" part of the use clause, I replaxed "Ext," with "Ext, ExtP,".  

With that we can use the "Caption" property of the "TExtButton" instances in the same way as we are accustomed to do with VCL/LCL GUI programming. :)

-Michael
« Last Edit: January 12, 2010, 12:30:09 pm by mschnell »

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #63 on: January 12, 2010, 01:16:07 pm »
Doing more test with the "visual" "TExt..." components. It looks like no state transfer from the Browser to the Application works:

 - TExtFormCheckbox: I always get the same Value for "Checked", even in the event procedure assigned to the CheckBox
 - TExtFormRadioGroup: I can't find a "runtime" property that would give the radiobutton that is pushed (ItemIndex only exist at design time)
 - TExtFormTextField: When reading the field e.g. in an event procedure of some Button, the property "Value" always gives the text initially assigned, instead of what I typed into the field with the Browser, .

Any further tip ?

-Michael
« Last Edit: January 12, 2010, 01:54:52 pm by mschnell »

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #64 on: January 12, 2010, 04:01:16 pm »
Doing more test with the "visual" "TExt..." components. It looks like no state transfer from the Browser to the Application works:

 - TExtFormCheckbox: I always get the same Value for "Checked", even in the event procedure assigned to the CheckBox
 - TExtFormRadioGroup: I can't find a "runtime" property that would give the radiobutton that is pushed (ItemIndex only exist at design time)
 - TExtFormTextField: When reading the field e.g. in an event procedure of some Button, the property "Value" always gives the text initially assigned, instead of what I typed into the field with the Browser, .

The ExtPascal FAQ page seems to suggest something like this:

Handler := Ajax(Server.Method, TExtFormBasicForm(AForm.getForm).getValues);

But with an ExtP application I don't see what I should do here. It does not know the identifiers "Server", "AForm" (, and Handler).

Any further tip ?

-Michael

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #65 on: January 12, 2010, 04:01:50 pm »
- a way to display asynchronous changes in the client's browser. I know that this is done with AJAX applications by having the JavaScript code poll the CGI-Application for (a notification of) changes, and to avoid too much traffic, the CGI application leaves such polling request "hanging" for a period shorter than the normal HTTP timeout, unless a change in fact is detected. (I don't know if something like this even is provided by ExtJS.In that case I'm out of the game here, being a Java illiterate).

What do you think ?
-Michael

Please ask questions like this on the ExtPascal forum, not here.

Thanks.

-Phil

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #66 on: January 12, 2010, 04:04:10 pm »
This is Ext JS, not VCL/LCL. Use the appropriate properties.
Of course. But seemingly the goal of EXTP is to maked ExtPascal (and thus ExtJS) more usable for educated Delphi/Lazarus/VCL/LCL users, by allowing them to use their beloved IDE to design a "Browser-GUI".

That's not the goal of ExtPascal. And one goal of the ExtP Toolkit is to use the ExtPascal properties as much as possible.

Thanks.

-Phil

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #67 on: January 12, 2010, 04:08:13 pm »
Doing more test with the "visual" "TExt..." components. It looks like no state transfer from the Browser to the Application works:

 - TExtFormCheckbox: I always get the same Value for "Checked", even in the event procedure assigned to the CheckBox
 - TExtFormRadioGroup: I can't find a "runtime" property that would give the radiobutton that is pushed (ItemIndex only exist at design time)
 - TExtFormTextField: When reading the field e.g. in an event procedure of some Button, the property "Value" always gives the text initially assigned, instead of what I typed into the field with the Browser, .

The ExtPascal FAQ page seems to suggest something like this:

Handler := Ajax(Server.Method, TExtFormBasicForm(AForm.getForm).getValues);

But with an ExtP application I don't see what I should do here. It does not know the identifiers "Server", "AForm" (, and Handler).

Any further tip ?

-Michael

Have you looked at the multiselect_example?

Thanks.

-Phil



mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #68 on: January 13, 2010, 12:04:40 pm »
Re-uniting the several discussion threads...

Hi Phil,
Sorry for me being confused ;) .

My long-time goal is doing embedded applications with Lazarus/Linux for processor boards without any GUI-hardware/GUI-framework, and porting existing Delphi applications to that target.

For these, I'd like to provide a Web-interface in a way as similar to the GUI of Delphi-applications as possible. Here I of course need a “free running” application, that can use Timers, TCP/IP, serial connections, etc ”in the background”, while no Browser is accessing the “Web-GUI”. Moreover, if a Browser is “connected” (i.e. showing a page of the “Web-GUI”), state changes introduced by the background tasks or by other Browser sessions, need to be reflected on the “Web-GUI” by updating the appropriate controls.

When I found ExtP, I was happy to see that there are tools that might be able to help me with that. The examples I found (on the ExtPascal Website), especially the “Progress-Bar” looked encouraging, as it seems to show the state of a running background process in realtime on the “Web-GUI”.

Now I looked into the source-code of the Progress-Bar example and found that it in fact is a fake: the continuous state changes are done by a Java script thingy running in the browser and not by a background processes on the server displaying it's state in realtime.

I never tried ExtPascal without ExtP. In fact in the beginning I thought that ExtPascal is just a part of ExtP and not decently usable without it. (That is why I had not choice but pestering you with my silly questions.)

I understand that I need to try to create an application with ExtPascal without using ExtP to understand what is happening there (e.g. if/how it's possible to communicate application states in realtime towards the browser without user interaction.)

Regarding the “Background work” in the FastCGI-application, I (fooled by the “Progress-Bar” example that I erroneously thought would be have been done with ExtP and erroneously thought would not be a fake) hoped that ExtP (which I found does not need the VCL/LCL binding) would implement a MainThread and a message queue in it's TApplication workalike. Now I know that it does not, but uses the TFCGIApplication (in FCGIapp.pas) or the TIdExtApplication (in IdExtHTTPServer) provided by ExtPascal, that both seemingly can't do that.

Do you know if/how ExtPascal can be used with a project based on the normal TApplication provided by the Delphi-VCL / Lazarus-LCL so that I can test what happens when a “Mainthread” is working in the background ? If that in fact does work and transferring application states into the browser GUI (see above) is possible, I might be inclined/able to rework TFCGIApplication and/or TIdExtApplication in a way according to the MSEGUI's “TNonGUIApplication” to enable event driven background MainThread programming with an ExtPascal WebGUI without VCL/LCL-binding.

So while seemingly not yet being the solution for the problems I face, maybe ExtP and ExtPascal are an excellent base to built this on (and feed back these option that additionally could be enabled into open source)....

This is Ext JS, not VCL/LCL. Use the appropriate properties.
Of course. But seemingly the goal of EXTP is to make ExtPascal (and thus ExtJS) more usable for educated Delphi/Lazarus/VCL/LCL users, by allowing them to use their beloved IDE to design a "Browser-GUI".
That's not the goal of ExtPascal. And one goal of the ExtP Toolkit is to use the ExtPascal properties as much as possible.
Yep, and this is GREAT and seems to work for the cases is meant for. But nonetheless IMHO it would be even greater it ExtP would preserve the functions of the well known VCL/LCL properties within the re-created work-alike classes as far as possible (such as Tbutton.Caption). This seemingly is not really hard to do (as I proved in my previous mail), but maybe it colud be a lot of work, regarding all the properties that we might want to handle.


Have you looked at the multiselect_example?
It does not compile with "WebServer" enabled ("Error: identifier idents no member Queries" in line 75, seemingly "CurrentThread.Queries"). It does compile without WebServer, but I can't test this yet, as I did not yet install a FastCGI enabled web server.

I commented out line 75 and now it compiles and it does work, :)
(Only after each Button click it additionally displays an error message "you must select an item. That seems to be caused by commenting out the offending line.)

(Some minutes later: I easily could add the property Queries to TIdExtHTTPServer. :) )

Nonetheless: I don't see why the Checkbox.Checked should not be able to be made work in a "normal" way by doing the "query" thingy in the appropriate class with a GetChecked function.

... But I can't find out what string to use in "Query" to get the checked state....
Seemingly in the multiselect example this is done by ExtUxFormMultiSelect1, but if I try to follow the example with my project, creating the appropriate "on" event, I get an error message "Access violation", when I load the form iin the browser. IMHO, no wonder as ExtUxFormMultiSelect1 never is created, But I don't find such a create in the multiselect example, either.

Thanks a lot for your work and your patience !!!
-Michael
« Last Edit: January 13, 2010, 02:29:18 pm by mschnell »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #69 on: January 13, 2010, 06:07:36 pm »
Michael,

Sounds like your ExtPascal is out of date if you don't have Queries in IdExtHTTPServer since I added Queries months ago. Upgrade to SVN.

There's also an easier way of getting data in the Ajax handler than using Query, but it depends on a fix that Wanderlan made this week. So upgrade to SVN.

Your threading questions should be directed to the ExtPascal forum so more knowledgeable people can see them.

The ExtP Toolkit design controls serve two main purposes, of which VCL/LCL property naming is not one of them:

- Visual design of Web pages. This is of middling importance but is useful to have.
- Generate Pascal code from the visual design. This is the real value, as figuring out how to do certain things in ExtPascal can be confusing. As I add support for more Ext JS properties, this value will only increase.

Thanks.

-Phil


Thanks.

-Phil

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #70 on: January 13, 2010, 07:34:17 pm »
There's also an easier way of getting data in the Ajax handler than using Query, but it depends on a fix that Wanderlan made this week. So upgrade to SVN.
Right now I'm using the older Version of ExtJS, as you suggested. Should/need I upgrade to the newer version to use with the current version of ExtPascal ?

I first need to find out if/how events from the server application can be pushed towards the browser via Ajax using the Java scripts that come with ExtJS. I can't work on the Java stuff, but I do know that I will be able to create add-ons for ExtPascal and for ExtP, that do not need major changes to the existing code but just a few lines included in {$ifdefs and some additional unit's I'd provide.

With that both my favorite enhancements could be done:

(1) (less important) many properties of the VCL/LCL workalike classes that are normally used in the user-code with VCL/LCL application can be used at runtime with EXTP (e.g. TExtButton.Caption can be written to and TExtFormChekbox.Checked can be read from)

(2) (more important) a Mainthread with Event-driven programming possibilities (e.g. TThread.Synchronize) is enabled without using any GUI binding. To make this useful I suppose we would need to create some additional components such as "TExtTimer").

-Michael

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #71 on: January 13, 2010, 07:53:26 pm »
The SVN version of ExtPascal works with both ExtJS 3.0.0 and 3.1.0.

Note that with SVN you don't have to generate Ext.pas, etc. yourself anymore, as they are included now. However, keep in mind that they were generated from the 3.1.0 docs - but they still work with 3.0.0 as long as you don't use properties that were introduced with 3.1.0 since these properties won't be in the 3.0.0 JS classes.

Thanks.

-Phil

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Status of toolkit for ExtPascal
« Reply #72 on: January 13, 2010, 07:55:29 pm »
I first need to find out if/how events from the server application can be pushed towards the browser via Ajax using the Java scripts that come with ExtJS. I can't work on the Java stuff, but I do know that I will be able to create add-ons for ExtPascal and for ExtP, that do not need major changes to the existing code but just a few lines included in {$ifdefs and some additional unit's I'd provide.

You probably just mistyped, but it's JavaScript, not Java - two unrelated languages.

Thanks.

-Phil

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #73 on: January 13, 2010, 08:06:18 pm »
Thanks, Phil, I'm at home now and will check your suggestions tomorrow.

I just took a look at the ExtJS website and found this example:

http://www.extjs.com/deploy/dev/examples/direct/direct.php

and this description:

http://www.extjs.com/products/extjs/direct.php

It looks very much as if here ExtJS indeed shows that it can handle serve-initiated updates of the controls in the Browser.

As I can't get much of Java, I don't understand how this works.

So this framework indeed seems to be usable for me. Now I need to find out if/how ExtPascal makes use of that.

(BTW.: This is what I meant by "hanging CGI Request:
http://en.wikipedia.org/wiki/Reverse_Ajax
http://en.wikipedia.org/wiki/Comet_%28programming%29 )

-Michael
« Last Edit: January 13, 2010, 08:28:13 pm by mschnell »

mschnell

  • Full Member
  • ***
  • Posts: 131
    • http://www.lumino.de
Re: Status of toolkit for ExtPascal
« Reply #74 on: January 13, 2010, 11:03:42 pm »
Please ask questions like this on the ExtPascal forum, not here.
How to do this ?
-Michael

 

TinyPortal © 2005-2018