Any Docs for THTMLDatasetContentProducer lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Michael Collier · 2012-02-24 17:05 I'd like to try THTMLDatasetContentProducer but didn't find anything on the wiki. Specifically I need details for producing the content, I guessed a few methods but didn't work. I tried the ProduceContent method (raised exception), do I need to use the other events to produce anything? The source mentions that this method is for testing only? The cgi works in all other respects, I can handle the action, open connection to MySQL, open query, etc and have set the actions ContentProducer property to HTMLDatasetContentProducer1 I was expecting/hoping to do something like this for the action OnRequest event Response.Content := HTMLDatasetContentProducer1.ProduceContent; Handled := True I can use HTML by hand and produce a
but would prefer to use this component ---------------------------------------------------------------------- devEric69 · 2020-05-14 07:27 Quote from: Michael Collier on February 24, 2012, 06:05:21 pmI was expecting/hoping to do something like this for the action OnRequest event Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i AResponse.Content := HTMLDatasetContentProducer1.ProduceContent;Handled := True;I can use HTML by hand and produce a
but would prefer to use this component Assuming that there is a TWebAction named act_get_my_html, you must ask to write in AResponse, the return of an internal stream (when answering with html Producer objects solution, we must use the methods of the writer, which manages a memory stream for a purpose of rapidity; no string type here like with the fpTemplate solution which uses text \ string processing in the Php way) by a recursive " foreach " that traverses the polymorphic objects of the THtmlCustomElement \ TDOMElement hierarchy written by aWriter forming a DOM Tree, with this call ( it's the Producer's job to convert its internal stream into text in the response; that's how the pattern was designed, although there is a text-html rendering method for debugging purposes only; caution: sometimes it returns '' in some overriden ProduceContent methods of the html DOM elements ): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFPWebModule1.act_get_my_htmlRequest(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean);begin  HTMLEntityProducer1.HandleRequest(ARequest, AResponse, Handled);  Handled := True;end; ~~~~~~~~ Here is another example, always with an html Producer object, allowing to create a web application RAD way, i.e. with drag-drop of components: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFPWebModule1.HTMLEntityProducer1WriteEntity(Sender: THTMLContentProducer; aWriter: THTMLWriter);begin  aWriter.Startbody;    aWriter.Startparagraph;      aWriter.heading2('Hello, world from inside §1');      aWriter.Text('Here is text written inside the current paragraph.');    aWriter.Endparagraph;    aWriter.paragraph('This is another text written inside a self "started and ended paragraph.');    aWriter.Startparagraph;      aWriter.heading2('Hello, world from inside §2');      aWriter.Text('Here is the final text.');    aWriter.Endparagraph;  aWriter.Endbody;end; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFPWebModule1.act_get_my_htmlRequest(Sender: TObject; ARequest: TRequest; AResponse: TResponse; var Handled: Boolean);begin  (*    ask HTMLEntityProducer1 for its objects DOM tree 's stream content:  *)  HTMLEntityProducer1.HandleRequest(ARequest, AResponse, Handled);  Handled := True;end; ---------------------------------------------------------------------- egsuh · 2020-06-08 11:43 Any progress on this? I'm looking at this component, to review the content of a dataset via web. I think this should display the content of a dataset in tabular format, without any further codes, but not. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    datasource1.dataset := sqlitedataset1;    dsetcont.datasource := datasource1;   webaction1.contentproducer := dsetcontent;   // dsetcontent = THTMLDataSetContentProducer   Using aWriter.... works for THTMLEntityProducer,  but not for THTMLDataSetContentProducer. ---------------------------------------------------------------------- devEric69 · 2020-06-08 15:33 For information, not knowing what you know about this component. I tried to make this component 100% operational, 2 weeks ago (I gave myself 2 days, not having more time; so I copied the unit in my project directory, and debugged it with LazLogger and "raise HTMLException"). The problem is the time - as usual - to find the 0,???1% of lines to modify ^^. Indeed, I think that writing with HTML words encapsulated in Pascal objects rather than using the template engine, only makes sense to me if it saves time. For a newbee - i know you're not - who doesn't know Web programming, but who knows how to create a database and how to create a .htaccess and a .htpassword files, using this component saves time. Quickly, from memory, roughly the idea seemed to me to be that we should create an HTML table (loop on SQL records, to create each HTML row), with creation of an "edit" button in the last column of each HTML row. There's a inter-pages HTML navigator provided, that can present, HTML table URL by HTML table URL, all x records of an SQL table. The "edit" button of each HTML row calls a server-side web action, which should display the single row for its edition (labels column, followed by the html controls column for input). And there should be  two buttons "save changes" and "undo changes". It's very far from ajax, but it's RAD which allows to hide technical problems for someone who wants to quickly publish and manage a SQL table, on the web or on an intranet. nb: when editing, it's called THTMLDatasetEditContentProducer i.e. it's one step further.