Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 10 total
Thread Dataset.load problem with German boolean literal
Sun, Feb 9 2014 9:10 AMPermanent Link

Uli Becker

Hi,

I got an error when trying to load rows into a dataset (JSON is served
by EWB webserver).

Finally I found out that the German literal for boolean values
('true#='wahr') is the culprit:

JSON from Webserver (simplified):

{   "rows": [
{ "PostenID": 40543, "RechnungenID": 1533, "Abzug": wahr },
....

Replacing 'wahr' by 'true' solves the problem:

{   "rows": [
{ "PostenID": 40543, "RechnungenID": 1533, "Abzug": true},
....

I searched the FormatSettings, but didn't find anything to adjust that.
Any idea?

Thanks Uli
Sun, Feb 9 2014 1:48 PMPermanent Link

Raul

Globestar Systems

Team Elevate Team Elevate

Uli,

Where does the "wahr" come from in the first place ?

JSON and EWB spec requires "true", "false" (and "null") literals. Any
localization has to be at the presentation/UI layer.

Raul


On 2/9/2014 9:10 AM, Uli Becker wrote:
> Hi,
>
> I got an error when trying to load rows into a dataset (JSON is served
> by EWB webserver).
>
> Finally I found out that the German literal for boolean values
> ('true#='wahr') is the culprit:
>
> JSON from Webserver (simplified):
>
> {   "rows": [
> { "PostenID": 40543, "RechnungenID": 1533, "Abzug": wahr },
> ...
>
> Replacing 'wahr' by 'true' solves the problem:
>
> {   "rows": [
> { "PostenID": 40543, "RechnungenID": 1533, "Abzug": true},
> ...
>
> I searched the FormatSettings, but didn't find anything to adjust that.
> Any idea?
>
> Thanks Uli
>
Mon, Feb 10 2014 4:24 AMPermanent Link

Uli Becker

Raul,

> Where does the "wahr" come from in the first place ?
>
> JSON and EWB spec requires "true", "false" (and "null") literals. Any
> localization has to be at the presentation/UI layer.

That's what I expected. Actually I nothing but sending a request and
getting back JSON by EWB server.
I investigated that once more and found out that the issue only occurs
when using a module ('customdatasets' calls a module):

http://localhost/labor/customdatasets?method=rows&dataset=patienten

result:

{   "rows": [
{ "PatientenID": 0, "PatientenNummer": "116536-001", "GDTID": null,
"Privat": wahr,
....

http://localhost/labor/datasets?method=rows&dataset=patientenall

result:

{   "rows": [
{ "PatientenID": 0, "PatientenNummer": "116536-001", "GDTID": null,
"Privat": true,

The module does nothing but this:

else if AnsiSameText(RequestParams.Values['method'], 'rows') then
      begin
        try
          SendCustomContent(DatasetAdapter.BuildRows('customdatasets'),
'application/json; charset=utf-8', '');
        except
          on E: Exception do
            SendError(HTTP_INTERNAL_ERROR, E.Message);
        end;
      end

Uli
Mon, Feb 10 2014 8:32 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< The module does nothing but this: >>

Did you define any persistent TFields in your module ?  If so, did you
change the DisplayValues property for the boolean TField(s) ?

I'll make sure that EWB overrides this in the next build, but fixing the
above will most likely fix the problem for now.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 10 2014 8:57 AMPermanent Link

Uli Becker

Tim,

> Did you define any persistent TFields in your module ?  If so, did you
> change the DisplayValues property for the boolean TField(s) ?

No, I didn't.

Uli
Mon, Feb 10 2014 8:58 AMPermanent Link

Uli Becker

Addition:

No, I didn't define any persistent fields.

Uli
Tue, Feb 11 2014 10:07 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< No, I didn't define any persistent fields. >>

Hmm, I'm wondering if the default Boolean text values are localized.  In my
copy, they're resource strings, but they default to "True" and "False".  At
any rate, it won't matter after the next build.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Feb 11 2014 10:07 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

Also, you should be able to fix this by changing the DisplayValues for the
relevant Boolean fields to 'True;False'.

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Feb 11 2014 11:47 AMPermanent Link

Uli Becker

Tim,

> Also, you should be able to fix this by changing the DisplayValues for
> the relevant Boolean fields to 'True;False'.

I can't do that because I use table components whiche are created at
runtime and thus not contain persistent fields.

Also the problem occurs only when using a module, *not* when loading the
same dataset from the EWB server directly.

As a workaround I now replace the literals in the JSON string before
sending it.

Uli
Wed, Feb 12 2014 8:44 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Uli,

<< I can't do that because I use table components whiche are created at
runtime and thus not contain persistent fields. >>

Of course you can - just use FieldByName() and set the resultant TField's
DisplayValues.

<< Also the problem occurs only when using a module, *not* when loading the
same dataset from the EWB server directly. >>

I'm not sure why you're seeing this - both use TFields and TDataSets in
exactly the same way.  I checked the code, it was exactly the same before I
changed it to use hard-coded JSON boolean string values.   The only thing I
can think of is that your version of Delphi uses different default string
values for Booleans, which makes sense if you're not using an English
version of Delphi.

Tim Young
Elevate Software
www.elevatesoft.com
Image