fpWeb Producers lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- egsuh · 2020-06-12 02:50 Recently I asked questions on "Producers" on the fpWeb (there are many producers on the fpWeb tab of component pallette) directly to Michael and he gave me very kind answers. I share them here with his consent. Quoted parts are my questions.  Quote> Currently I've built an on-line survey platform web-server using > fpWeb, which is quite satisfactory. And I'm extending my program to > display the progress. > > For this, I guessed that components on the fpWeb tab, e.g. > THTMLDataSetContentProducer, etc., are very useful, but I cannot > figure out how to define properties / methods for them. > > > My rough guess is the content of the dataset would be displayed on the > browser with just following assignments, but this displays nothing. > > > > datasource1.dataset := sqlitedataset1; dsetcont.datasource := > datasource1; > > webaction1.contentproducer := dsetcontent;   // > dsetcontent = THTMLDataSetContentProducer The THTMLDataSetContentProducer is completely event based. This means you must set the OnWriteHeader, OnWriteFooter, OnWriteRecord events to actually produce the HTML. The component will call OnWriteHeader once, call OnWriteRecord for each record, and then calls OnWriteFooter once more. If you want to produce a table, you can use the THTMLDatasetFormShowProducer; it will produce a standard HTML table. Quote> So I hope that you can provide us the very basic explanations / > examples. Then we would be able to figure out other features. To be honest, I would no longer recommend the use of these components. I do a lot of web development, and I moved away from generating HTML on the server. My servers only provide RPC and REST mechanisms, all layout is done in the browser using Javascript scripting. I write the scripts using pas2js, see https://wiki.freepascal.org/pas2js I do not know your level of technical expertise, but you may want to check it out. Lazarus has very good pas2js integration. However, of you feel that server-side generation of HTML is more suitable for you, do please continue, and feel free to ask questions. Michael. ---------------------------------------------------------------------- Leledumbo · 2020-06-13 19:26 Indeed today's standard web applications are no longer monolithic. At the worst separate the frontend and backend by using API of any kind as the communication contract. Backend should only provide data, not the formatted data, as it's the frontend's responsibility to format (and layout) it. ---------------------------------------------------------------------- egsuh · 2020-06-14 00:59 QuoteBackend should only provide data, not the formatted data, as it's the frontend's responsibility to format (and layout) it. Yes. No problem on this. We have many ways to solve an issue. I was just interested whether fpWeb Producers could be the least- effort approach to display some content of database (I defined a View so just displaying the view is good enough). ---------------------------------------------------------------------- devEric69 · 2020-06-14 08:54 For information, I think it might be possible to save time in development {f-}CGI, with pascalscript (https://github.com/remobjects/pascalscript/wiki/Using-RemObjects- Pascal-Script). The idea would be to code the events in interpreted code (like Php). So, it would be necessary to pass the addresses of ARequest, Session, ModuleTemplate pointers, etc, to the Pascal interpreter (this is a feature already provided by pascalscript), and then to call only if oPascalscript.Compile(doInterpretedStuff) then oPascalscript.Execute(doInterpretedStuff) from the event of an interpreted method, in the said events. Of course, the tuning remains to be done with a text log; but the compilations could often be shunted (to be tested!).