Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-04

fcl-web or BrookFramework queryfields array

9 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

silvioprog
to Leonardo M. Ramé
Leonardo M. Ram? wrote 6 lines
Hi, I need to extract the field values of a GET query of type: http://127.0.0.1/cgi-bin/test.cgi?fields[1]=f1value&fields[2]=f2value Is there a way to handle this apart from HttpRequest.QueryFields?

Yes.

Supposing you have an object called "TQuery" with the published property "Fields", you can do it easily with the "TBrookParser" object. Take a look at this demo:

http://pastebin.com/QEh5Hnen

I've been using the "Fields" property as "TStringList", but you can use any list type, just creating a list adapter for that.

Feel free to use the Brook community
<https://plus.google.com/u/0/communities/101133820055678331036> too! :-)

Regards,

Silvio Cl?cio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160415/b52e0967/attachment.html>

Reply by email

Leonardo M. Ramé
to Michael Van Canneyt

El 15/04/16 a las 16:22, Michael Van Canneyt escribi?:

Show quoted text 13 lines
On Fri, 15 Apr 2016, Leonardo M. Ram? wrote: > Hi, I need to extract the field values of a GET query of type: > > http://127.0.0.1/cgi-bin/test.cgi?fields[1]=f1value&fields[2]=f2value > > Is there a way to handle this apart from HttpRequest.QueryFields? What other way would you like ? What is not good about this way ? Michael.

It works pefectly por param=value&..., but I don't know how to parse array type values.

example: ?filters[0]['filter']=name&filters[0]['value']=john

Regards,

Leonardo M. Ram? Medical IT - Griensu S.A. Av. Col?n 636 - Piso 8 Of. A X5000EPT -- C?rdoba Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19 Cel.: +54 9 (011) 40871877

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ram? wrote 21 lines
El 15/04/16 a las 16:22, Michael Van Canneyt escribi?: > > > On Fri, 15 Apr 2016, Leonardo M. Ram? wrote: > >> Hi, I need to extract the field values of a GET query of type: >> >> http://127.0.0.1/cgi-bin/test.cgi?fields[1]=f1value&fields[2]=f2value >> >> Is there a way to handle this apart from HttpRequest.QueryFields? > > What other way would you like ? What is not good about this way ? > > Michael. It works pefectly por param=value&..., but I don't know how to parse array type values. example: ?filters[0]['filter']=name&filters[0]['value']=john

What is the problem ? Everything before a = is the name ?

So:

Name:=Request.QueryFields.values['filters[0][''filter'']'];
Value:=Request.QueryFields.values['filters[0][''value'']'];

It doesn't automatically convert them to arrays, obviously. For that you need to know how the array (in this case double array) is encoded.

Microsoft uses() in it's query names, like in:

?filters(0,'filter')=name&filters(0,'value')=john

I see no need to provide routines for this.

Michael.

Reply by email

silvioprog
to Leonardo M. Ramé: El 15/04/16 a las 16:22, Michael Van Canneyt escribi?: It works pefectly por…

On Fri, Apr 15, 2016 at 4:25 PM, Leonardo M. Ram?
wrote:
[...]

It works pefectly por param=value&..., but I don't know how to parse array type values. example: ?filters[0]['filter']=name&filters[0]['value']=john

This filter can be easily parser if you send it as:

?filters[0].filter=name&filters[0].value=john

The parser can populate a class structure like:

=== code ===

  TYourObject = class
  published
    property filter: string ...;
    property value: string ...;
  end;
  TFilters = class(TFPGMapObject<TYourObject>)
  end;

=== /code ===

Silvio Cl?cio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160415/1cb6f7a3/attachment.html>

Reply by email

Leonardo M. Ramé
to silvioprog: On Fri, Apr 15, 2016 at 4:25 PM, Leonardo M. Ram? [...] This filter can be easily parser…

El 15/04/16 a las 16:33, silvioprog escribi?:

Show quoted text 29 lines
On Fri, Apr 15, 2016 at 4:25 PM, Leonardo M. Ram? < <mailto:>> wrote: [...] It works pefectly por param=value&..., but I don't know how to parse array type values. example: ?filters[0]['filter']=name&filters[0]['value']=john This filter can be easily parser if you send it as: ?filters[0].filter=name&filters[0].value=john The parser can populate a class structure like: === code === TYourObject = class published property filter: string ...; property value: string ...; end; TFilters = class(TFPGMapObject<TYourObject>) end; === /code ===

Sorry, nevermind. I've found a way to configure KendoUi Grid to send queries as POST using JSON, so, problem solved.

Reply by email

silvioprog
to Leonardo M. Ramé

On Fri, Apr 15, 2016 at 4:37 PM, Leonardo M. Ram?
wrote:
[...]

Sorry, nevermind. I've found a way to configure KendoUi Grid to send queries as POST using JSON, so, problem solved.

Awesome. :-)

tip: you can use jQuery $.param before sent the JSON filter to FCL-web/Brook, and decode it with HTTPDecode()+FPJson in the server. :-)

Silvio Cl?cio -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20160415/45dcc9cc/attachment.html>

Reply by email