Skip to content

Commit 6bd256b

Browse files
authored
Merge pull request #1146 from ako/main
Sync ako/mxcli: page round-trip fidelity, check/exec agreement, domain-model and security fixes
2 parents 9c5a837 + 5741e8c commit 6bd256b

55 files changed

Lines changed: 3193 additions & 131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/commands/mendix/lint.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ mxcli lint -p app.mpr --exclude System --exclude Administration
4040
| MPR005 | quality | ImageSource - IMAGE widgets with no source configured |
4141
| MPR006 | quality | EmptyContainer - Empty layout containers |
4242
| MPR007 | security | PageNavigationSecurity - Navigation pages need allowed roles (CE0557) |
43+
| MPR012 | correctness | LegacyImageWidget - staticimage/dynamicimage are unsupported by the React client (CE0582) |
4344
| SEC001 | security | NoEntityAccessRules - Persistent entities need access rules |
4445
| SEC002 | security | WeakPasswordPolicy - Password minimum length should be 8+ |
4546
| SEC003 | security | DemoUsersActive - Demo users should be off at Production security |

‎.claude/skills/fix-issue/findings/mdl-backend.jsonl‎

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.

‎.claude/skills/fix-issue/findings/mdl-executor.jsonl‎

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.

‎.claude/skills/mendix/alter-page/SKILL.md‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ set Action = SHOW_PAGE Module.DetailPage on btnEdit
127127

128128
-- Rebind a data-bound widget
129129
set DataSource = $OrderParam on dvOrder
130-
set DataSource = DATABASE Module.Order on dgOrders
130+
set DataSource = microflow Module.MF_Get on dvOrder
131131
```
132132

133133
**Prefer `set Action` over `replace` when only the action changes.** `replace`
@@ -198,7 +198,6 @@ from a microflow to a page parameter:
198198
```sql
199199
ALTER PAGE MyModule.OrderPage {
200200
SET DataSource = $Order ON dvOrder; -- page/snippet parameter
201-
SET DataSource = database MyModule.Order ON dgOrders; -- database
202201
SET DataSource = microflow MyModule.MF_Get ON dvOrder; -- microflow
203202
SET DataSource = nanoflow MyModule.NF_Get ON dvOrder; -- nanoflow
204203
SET DataSource = selection dgOrders ON dvDetail; -- listen to widget
@@ -209,9 +208,23 @@ The parameter must exist on the page (or snippet) being altered — its entity i
209208
read from the container's own parameter list, and an unknown name is refused
210209
rather than written as an unresolved reference.
211210

212-
`association` sources are **not** supported by SET. Use REPLACE for those, which
213-
rebuilds the widget through the CREATE PAGE path and handles every datasource
214-
type; the error message says so.
211+
`association` and `database` sources are **not** supported by SET. Use REPLACE
212+
for those, which rebuilds the widget through the CREATE PAGE path and handles
213+
every datasource type; the error message says so.
214+
215+
A `database` source has no single stored shape — the widget holding it decides
216+
which element Mendix writes (a list view, a data grid and a pluggable widget
217+
each store a different one), and SET writes the property directly rather than
218+
rebuilding the widget, so it has nothing to choose from. This used to be
219+
accepted and half-applied: the widget was left with a source that DESCRIBE read
220+
back as absent and mxbuild rejected as **CE7007**, on a page `exec` had just
221+
reported as altered (mendixlabs/mxcli#1032).
222+
223+
A **data view** is the one case REPLACE does not rescue: it binds to a single
224+
object, so Mendix gives it no database form at all and the CREATE PAGE path
225+
refuses one too. Point it at a context parameter, a microflow, a nanoflow or
226+
`selection <widget>`, and use a list view or a data grid to show a query. The
227+
refusal says which of the two situations you are in.
215228

216229
### INSERT - Add Widgets
217230

‎.claude/skills/mendix/create-page/SKILL.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Both are optional and can be changed later with `alter page … { set Class = '
6767
| Widget name | Required after type | `textbox txtName (...)` |
6868
| Attribute binding | `attribute: AttrName` | `textbox txt (label: 'Name', attribute: Name)` |
6969
| Attribute over an association | `attribute: Assoc/Attr` (bare association name, multi-hop OK) | `textbox txt (label: 'Rule', attribute: RuleAction_BusinessRule/Name)` |
70+
| Password field | `Password: true` | `textbox tbPw (attribute: Secret, Password: true)` |
71+
| Widget validation | `Validation: '<expr>'` + `ValidationMessage: '<text>'` | `Validation: 'length(toString($value)) > 0'` — quoted, not `[bracketed]` |
7072
| Variable binding | `datasource: $Var` | `dataview dv (datasource: $Product) { ... }` |
7173
| Action binding | `action: type` | `actionbutton btn (caption: 'Save', action: save_changes)` |
7274
| Database source | `datasource: database entity` | `datagrid dg (datasource: database Module.Entity)` |
@@ -433,6 +435,11 @@ DATAVIEW dv (DataSource: $Issue) {
433435

434436
A bare association name is qualified with the module of the entity the widget
435437
sits on. On a ComboBox that matters: its `DataSource:` is the *option list*, but
438+
A text box that holds a secret needs `Password: true`. It is not cosmetic: without
439+
it the field renders the value in plaintext, and before ako/mxcli#550 a
440+
`describe page` → `exec` round trip silently turned every stored password field
441+
into an ordinary one — so copying a login or change-password page lost it.
442+
436443
An input widget can also *traverse* an association to show a value from the
437444
other side: `attribute: Assoc/Attr` binds the far attribute and stores the hops,
438445
which is what Studio Pro does. It works on textbox, textarea, datepicker,

‎.claude/skills/mendix/create-page/reference/widgets.md‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,13 @@ staticimage imgAllSelected (Image: 'MyFirstModule.Images.gallery')
698698
auto units and a responsive image — which `describe page` also omits, so a
699699
round trip neither loses them nor invents them.
700700

701-
Mendix 11's React client reports **CE0582** for `staticimage` wherever it
702-
appears — it is deprecated in favour of the pluggable `image` widget, which
703-
takes the same `Image:`. mxcli still writes it, because round-tripping a model
704-
that already contains one is the point; prefer `image` on a new page.
701+
**CE0582** is reported for `staticimage` wherever it appears, by any app running
702+
the React client — which Mendix added in **10.7** and which is the only client on
703+
11, so this is not a Mendix 11 rule. The replacement is the pluggable `image`
704+
widget, which takes the same `Image:`; Studio Pro offers the conversion from the
705+
CE0582 error's context menu. mxcli still writes it, because round-tripping a
706+
model that already contains one is the point — and `mxcli lint` reports it as
707+
**MPR012** so a new page does not reach for it by accident.
705708

706709
#### `DataSource:` — which object a DYNAMICIMAGE shows
707710

@@ -729,8 +732,9 @@ same three-part way as `staticimage`'s `Image:`. `WidthUnit:`/`HeightUnit:`,
729732
written; leave them out for Mendix's defaults (auto, responsive, full size, no
730733
enlarge), which `describe page` also omits.
731734

732-
CE0582 applies here too — `dynamicimage` is deprecated alongside `staticimage`,
733-
and the pluggable `image` widget is the replacement for both.
735+
CE0582 applies here too — the React client supports neither legacy image widget,
736+
and the pluggable `image` widget is the replacement for both. `mxcli lint` reports
737+
either as **MPR012**.
734738

735739
#### Setting Image Source (PLUGGABLEWIDGET syntax)
736740

‎cmd/mxcli/cmd_lint.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ func builtinLintRules() []linter.Rule {
381381
rules.NewDomainModelSizeRule(),
382382
rules.NewValidationFeedbackRule(),
383383
rules.NewImageSourceRule(),
384+
rules.NewLegacyImageWidgetRule(),
384385
rules.NewEmptyContainerRule(),
385386
rules.NewGallerySelectionListenerRule(),
386387
rules.NewDataViewLayoutGridRule(),

‎cmd/mxcli/syntax/features_page.go‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func init() {
1212
"page", "pages", "form", "UI", "user interface",
1313
"widget", "layout", "screen",
1414
},
15-
Syntax: "CREATE PAGE Module.Name\n (\n Title: 'Page Title',\n Layout: Module.LayoutName\n [, Params: { $Param: Module.Entity }]\n [, Url: 'page-url']\n [, Folder: 'FolderPath']\n [, Variables: { $var: Boolean = 'true' }]\n [, PopupWidth: 800, PopupHeight: 480, PopupResizable: true]\n [, Class: 'css-class', Style: 'css: rule']\n )\n {\n -- widgets\n }",
15+
Syntax: "CREATE PAGE Module.Name\n (\n Title: 'Page Title',\n Layout: Module.LayoutName\n [, Params: { $Param: Module.Entity }]\n [, Url: 'page-url']\n [, Folder: 'FolderPath']\n [, Variables: { $var: Boolean = 'true' }]\n [, PopupWidth: 800, PopupHeight: 480, PopupResizable: true]\n [, PopupCloseAction: cancelButton1]\n [, Class: 'css-class', Style: 'css: rule']\n )\n {\n -- widgets\n }",
1616
Example: "CREATE PAGE MyModule.EditCustomer\n (\n Params: { $Customer: MyModule.Customer },\n Title: 'Edit Customer',\n Layout: Atlas_Core.PopupLayout,\n Class: 'container-fluid'\n )\n {\n DATAVIEW dvCustomer (DataSource: $Customer) {\n TEXTBOX txtName (Label: 'Name', Attribute: Name)\n FOOTER footer1 {\n ACTIONBUTTON btnSave (Caption: 'Save', Action: SAVE_CHANGES, ButtonStyle: Primary)\n ACTIONBUTTON btnCancel (Caption: 'Cancel', Action: CANCEL_CHANGES)\n }\n }\n }",
1717
SeeAlso: []string{"page.create", "page.widgets", "page.alter", "snippet"},
1818
})
@@ -166,9 +166,11 @@ CREATE PAGE Sales.Detail (Title: 'Detail', Layout: Atlas_Core.Atlas_Default) {
166166
"-- so a stored one round-trips through DESCRIBE (mendixlabs/mxcli#1057). Without\n" +
167167
"-- it the widget is written with no image and mxbuild reports CE0436:\n" +
168168
"STATICIMAGE imgLogo (Image: 'MyModule.Images.logo', Width: 64, Height: 64)\n\n" +
169-
"-- Deprecated in the Mendix 11 React client. These are written correctly by\n" +
170-
"-- both engines, but mxbuild reports CE0582 (\"not supported in React client\")\n" +
171-
"-- on each, so prefer the alternative:\n" +
169+
"-- Not supported by the React client — added in Mendix 10.7, and the only\n" +
170+
"-- client on 11, so this is not a Mendix 11 rule. These are written correctly,\n" +
171+
"-- but mxbuild reports CE0582 (\"not supported in React client\") on each\n" +
172+
"-- wherever that client is enabled, and `mxcli lint` reports them as MPR012.\n" +
173+
"-- Prefer the alternative:\n" +
172174
"-- STATICIMAGE -> IMAGE\n" +
173175
"-- DYNAMICIMAGE -> IMAGE\n" +
174176
"-- DROPDOWN -> COMBOBOX\n" +
@@ -275,7 +277,7 @@ CREATE PAGE Sales.Detail (Title: 'Detail', Layout: Atlas_Core.Atlas_Default) {
275277
"popup width", "popup height", "popup resizable",
276278
"drop template", "insert template", "list view template",
277279
},
278-
Syntax: "ALTER PAGE Module.Name {\n SET property = value ON widgetName; -- widget property names: any casing\n SET Action = MICROFLOW Module.MF ON btnSave; -- any CREATE PAGE action form\n SET DataSource = $Param ON dvOrder;\n SET (prop1 = val1, prop2 = val2) ON widgetName;\n SET Title = 'New Title'; -- page-level (case-sensitive)\n SET Documentation = 'What this page is for.';\n SET Class = 'css-class'; -- page-level CSS class / style\n SET Style = 'css: rule';\n SET PopupWidth = 800; -- page-level pop-up dimensions\n SET PopupHeight = 480;\n SET PopupResizable = true;\n INSERT AFTER widgetName { <widgets> };\n INSERT BEFORE widgetName { <widgets> };\n INSERT INTO containerName { <widgets> };\n DROP WIDGET name1, name2;\n DROP TEMPLATE FOR Module.Specialization IN listViewName;\n REPLACE widgetName WITH { <widgets> };\n};",
280+
Syntax: "ALTER PAGE Module.Name {\n SET property = value ON widgetName; -- widget property names: any casing\n SET Action = MICROFLOW Module.MF ON btnSave; -- any CREATE PAGE action form\n SET DataSource = $Param ON dvOrder; -- parameter/microflow/nanoflow/selection;\n -- DATABASE and association are REPLACE-only,\n -- and a data view takes no database source\n SET (prop1 = val1, prop2 = val2) ON widgetName;\n SET Title = 'New Title'; -- page-level (case-sensitive)\n SET Documentation = 'What this page is for.';\n SET Class = 'css-class'; -- page-level CSS class / style\n SET Style = 'css: rule';\n SET PopupWidth = 800; -- page-level pop-up dimensions\n SET PopupHeight = 480;\n SET PopupResizable = true;\n INSERT AFTER widgetName { <widgets> };\n INSERT BEFORE widgetName { <widgets> };\n INSERT INTO containerName { <widgets> };\n DROP WIDGET name1, name2;\n DROP TEMPLATE FOR Module.Specialization IN listViewName;\n REPLACE widgetName WITH { <widgets> };\n};",
279281
Example: "ALTER PAGE Module.EditPage {\n SET (Caption = 'Save & Close', ButtonStyle = Success) ON btnSave;\n INSERT AFTER txtName {\n TEXTBOX txtMiddleName (Label: 'Middle Name', Attribute: MiddleName)\n };\n DROP WIDGET txtUnused;\n};",
280282
SeeAlso: []string{"page.create", "page.show", "snippet.alter"},
281283
})

‎docs/01-project/MDL_QUICK_REFERENCE.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,8 @@ MDL uses explicit property declarations for pages:
13791379
|---------|-----------|---------|
13801380
| Page properties | `(key: value, ...)` | `(title: 'Edit', layout: Atlas_Core.Atlas_Default)` |
13811381
| Pop-up dimensions | `PopupWidth: n, PopupHeight: n, PopupResizable: bool` | `(Layout: Atlas_Core.PopupLayout, PopupWidth: 800, PopupHeight: 480, PopupResizable: true)` — case-sensitive; default 600×600 |
1382+
| Pop-up close button | `PopupCloseAction: <widgetName>` | `(Layout: Atlas_Core.PopupLayout, PopupCloseAction: cancelButton1)` — names a widget on this page. Not carried from the stored document on a rewrite: the statement rebuilds the widget tree, so a carried name could dangle |
1383+
| DataView read-only style | `ReadOnlyStyle: Inherit\|Control\|Text` | `dataview dv (datasource: $O, ReadOnlyStyle: Text)` — a DataView's own, distinct from a checkbox's. **Control** is Studio Pro's default here, not Inherit |
13821384
| Page CSS class / style | `Class: 'css-class', Style: 'css: rule'` | `(Title: 'Home', Class: 'container-fluid bg-light', Style: 'min-height: 100vh')` — the page's Appearance |
13831385
| Page variables | `variables: { $name: type = 'expr' }` | `variables: { $show: boolean = 'true' }` |
13841386
| Repeated widget entries | `<container> <name> ( … )` **in the widget body** | A repeatable property (FileUploader `allowedFileFormats`, HTML Element `attributes`, a chart's `series`) is a block, never a property value. `attributes: [(attributeName: 'x')]` is **MDL-WIDGET27** — it used to check clean, exec, and vanish from storage. `describe widget <name> -p app.mpr` lists the container keywords |
@@ -1388,6 +1390,8 @@ MDL uses explicit property declarations for pages:
13881390
| Widget name | Required after type | `textbox txtName (...)` |
13891391
| Attribute binding | `attribute: AttrName` | `textbox txt (label: 'Name', attribute: Name)` |
13901392
| Attribute over an association | `attribute: Assoc/Attr` (bare association name, multi-hop OK) | `textbox txt (label: 'Rule', attribute: RuleAction_BusinessRule/Name)` — works on textbox, textarea, datepicker, dropdown, checkbox and radiobuttons, the same as on a data grid column |
1393+
| Password field | `Password: true` on a textbox | `textbox tbPw (attribute: Secret, Password: true)` — omitted when false. Without it a describe → exec round trip turns a password field into a plaintext one |
1394+
| Widget validation | `Validation: '<expression>'`, `ValidationMessage: '<text>'` | `Validation: 'length(toString($value)) > 0'` — a Mendix expression over `$value`, QUOTED not bracketed (`[...]` is the XPath spelling and parses as an array) |
13911395
| Variable binding | `datasource: $Var` | `dataview dv (datasource: $Product) { ... }` |
13921396
| Action binding | `action: type` | `actionbutton btn (caption: 'Save', action: save_changes)` — the forms are a closed set (`mxcli syntax page.action`); anything else is **MDL-WIDGET28** |
13931397
| No action | `action: nothing` | `actionbutton btn (caption: 'Decorative', action: nothing)` — an explicitly inert control. Write it deliberately: an action keyword **short its argument** (`action: open_link` with no URL) is now an error rather than a widget silently written with no action at all |
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
-- mendixlabs/mxcli#1032 — `SET DataSource = DATABASE …` silently wiped a
2+
-- DataView's datasource
3+
--
4+
-- The reported statement
5+
--
6+
-- ALTER PAGE Test.MyPage { SET DataSource = DATABASE Test.Customer ON dvCust; };
7+
--
8+
-- passed `check`, ran to `Altered page …` with exit 0, and left the DataView
9+
-- with no usable datasource at all. `DESCRIBE PAGE` read the widget back as
10+
-- `dataview dvCust {` with the property gone, and the only other signal was
11+
-- CE7007 at build time — naming the widget, never the statement that broke it.
12+
--
13+
-- Cause: one mapping standing in for several. A DATABASE source has no single
14+
-- stored shape; the widget holding it decides which element Studio Pro writes —
15+
-- Forms$ListViewXPathSource on a list view, CustomWidgets$CustomWidgetXPathSource
16+
-- on a pluggable widget, Forms$GridXPathSource on a grid. A DATA VIEW has no
17+
-- database form at all: it binds to ONE object, which is why CREATE PAGE's own
18+
-- builder refuses that pairing. The mutator instead wrote a Forms$DataViewSource
19+
-- — the "data from context" source — with the entity in EntityRef and
20+
-- SourceVariable left null, which is neither shape and is why DESCRIBE (whose
21+
-- context reader needs a SourceVariable) rendered nothing.
22+
--
23+
-- Measured on a real Mendix 11.13.0 app, two copies of the same project:
24+
--
25+
-- with the fault mxcli check --references → "Check passed!"
26+
-- mxcli exec → "Altered page …", exit 0
27+
-- describe page → dataview dvCust { … } (no source)
28+
-- mx check → 1 error, CE7007 at Data view 'dvCust'
29+
--
30+
-- with the fix mxcli check --references → refused, exit 1
31+
-- mxcli exec → refused, exit 1
32+
-- describe page → datasource unchanged
33+
-- mx check → 0 errors
34+
--
35+
-- The refusal lives once, in the mutator, so `check` (which dry-runs the SET
36+
-- against a throwaway copy of the stored document) and `exec` cannot disagree.
37+
-- It needs the document to know the widget's type, so it fires under `-p`; this
38+
-- file is therefore the PASSING shape, with the refused statements commented.
39+
--
40+
-- Run: mxcli check mdl-examples/bug-tests/1032-alter-page-set-database-datasource.mdl
41+
-- mxcli exec mdl-examples/bug-tests/1032-alter-page-set-database-datasource.mdl -p app.mpr
42+
43+
create module P1032;
44+
create persistent entity P1032.Customer (Name: String(200));
45+
46+
create microflow P1032.MF_GetCustomer () returns P1032.Customer as $Result
47+
begin
48+
retrieve $Result from P1032.Customer limit 1;
49+
end;
50+
51+
create page P1032.CustomerPage (
52+
params: { $Customer: P1032.Customer },
53+
title: 'Customer',
54+
layout: Atlas_Core.Atlas_Default
55+
) {
56+
layoutgrid g { row r { column c (desktopwidth: 12) {
57+
-- A LIST VIEW is where a database query belongs. Authored here through
58+
-- CREATE PAGE, which builds the Forms$ListViewXPathSource the widget needs.
59+
listview lvCustomers (datasource: database P1032.Customer) {
60+
textbox tbListName (attribute: Name, label: 'Name')
61+
}
62+
-- The DataView from the report, on a microflow source.
63+
dataview dvCust (datasource: microflow P1032.MF_GetCustomer) {
64+
textbox tbName (attribute: Name, label: 'Name')
65+
}
66+
} } }
67+
}
68+
69+
-- The sources a DataView really takes still retype through SET, unchanged by
70+
-- the refusal — the control that says this fixes #1032 rather than replacing it
71+
-- with a blanket "no".
72+
alter page P1032.CustomerPage {
73+
set DataSource = $Customer on dvCust;
74+
}
75+
76+
alter page P1032.CustomerPage {
77+
set DataSource = microflow P1032.MF_GetCustomer on dvCust;
78+
}
79+
80+
alter page P1032.CustomerPage {
81+
set DataSource = selection lvCustomers on dvCust;
82+
}
83+
84+
-- REFUSED, both by `check -p --references` and by `exec` (uncomment to see):
85+
--
86+
-- alter page P1032.CustomerPage {
87+
-- set DataSource = database P1032.Customer on dvCust;
88+
-- }
89+
--
90+
-- a data view cannot take a database datasource — a data view binds to a
91+
-- single object, so its source is a context parameter (`$Param`), a
92+
-- microflow, a nanoflow or `selection <widget>`; to show the result of a
93+
-- database query, use a list view or a data grid instead
94+
--
95+
-- The same statement against the LIST VIEW is refused too, but for the other
96+
-- reason and with the other remedy — a list view can hold a database source,
97+
-- SET just cannot build one, so the message names the path that can:
98+
--
99+
-- alter page P1032.CustomerPage {
100+
-- set DataSource = database P1032.Customer on lvCustomers;
101+
-- }
102+
--
103+
-- setting a database datasource on "lvCustomers" (Forms$ListView) is not
104+
-- supported by `set` — its stored shape depends on the widget and is built
105+
-- by the CREATE PAGE path; use `replace <widget> with …` instead, which
106+
-- rebuilds the widget through that path

0 commit comments

Comments
 (0)