Project

General

Profile

Actions

Bug #2852

closed

WFormModel issue / Wrong wording in widget gallery example

Added by Stefan Arndt about 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
03/24/2014
Due date:
% Done:

0%

Estimated time:

Description

There is an issue related to your wording in the integration example (Wt Widget Gallery->Forms).

Using a FormModel and a View:

class MyModel : public Wt::WFormModel

{

public:

static constexpr Field Title_Field = "article-title";

//static const Field Title_Field;

};

Your example (http://www.webtoolkit.eu/widgets/forms/integration-example) says, it's totaly valid to use the c++11 approach. Well, I don't think so.

Try to set a model value from inside MyModel using "setValue(Title_Field,X)" and additionaly from the view via "model->setValue(MyModel::Title_Field,X)" and you end up with having 2 fields.

They are both named "article-title", but they are distinct, since you are using a "const char*" as Field-Type, which is itsel the key in your field map (https://github.com/kdeforche/wt/blob/master/src/Wt/WFormModel). Because "static constexpr Field" does not guarantee the pointers to be equal, this leads to nasty bugs.

I would prefer defining the Field as std::string, but at least you might want to correct (or place an explicit hint) on your integration example, that the C++11-approach does not work.

Actions #1

Updated by Koen Deforche about 10 years ago

  • Status changed from New to InProgress
  • Target version set to 3.3.3
Actions #2

Updated by Koen Deforche about 10 years ago

  • Status changed from InProgress to Resolved

Hey,

It's unfortunate that the C++11 short-cut cannot be taken (since constexpr will not generate the unique storage needed for our purposes). I'm removing this comment.

But I would prefer to stick to the 'const char *' based Fields, simply because it avoids a lot of string comparisons while trying to look-up a particular field. Using a std::string just seems like a large price to pay for minimal developer comfort improvements. But I realize it's debatable. I'm also updating the documentation of WFormModel to point out this caveat.

Regards,

koen

Actions #3

Updated by Koen Deforche almost 10 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF