بنقرة واحدة
alter-page
ALTER PAGE / ALTER SNIPPET — SET, INSERT, DROP, REPLACE widget operations on existing pages and snippets
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
ALTER PAGE / ALTER SNIPPET — SET, INSERT, DROP, REPLACE widget operations on existing pages and snippets
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Mendix MDL authoring, project navigation, and Docker app lifecycle — entities, microflows, pages, security, navigation, OQL, REST, testing, linting, and migration. Load when working in any Mendix codebase.
MDL Agent Documents — CREATE MODEL, CREATE KNOWLEDGE BASE, CREATE CONSUMED MCP SERVICE, CREATE AGENT syntax and calling agents from microflows
Migration Assessment — structured investigation of non-Mendix projects for migration planning across technology stack, data model, business logic, UI, integrations, and security
Assess Mendix Project Quality — automated linting, catalog queries, naming conventions, security, maintainability, performance, and architecture review with scored report
Browse Integration Services and Contracts — SHOW/DESCRIBE OData, REST, business event, and database connection services; query MDL CATALOG integration tables; import external entities
Bulk Widget Property Updates — SHOW WIDGETS discovery and UPDATE WIDGETS dry-run/apply across pages and snippets
| name | alter-page |
| description | ALTER PAGE / ALTER SNIPPET — SET, INSERT, DROP, REPLACE widget operations on existing pages and snippets |
| compatibility | opencode |
MDL page/snippet editor — targeted in-place modifications to existing pages and snippets without full rebuild.
ALTER PAGE and ALTER SNIPPET modify an existing page or snippet's widget tree in-place without requiring a full create or replace. Operations work directly on the raw BSON tree, preserving widget types and properties that MDL doesn't explicitly model.
| Scenario | Use |
|---|---|
| Change a button caption, label, or style | alter page with set |
| Add a field to an existing form | alter page with insert |
| Remove unused widgets | alter page with drop |
| Replace a footer or section | alter page with replace |
| Rebuild entire page from scratch | create or replace page |
| Create a new page | create page |
Rule of thumb: Use alter page for targeted edits to a few widgets. Use create or replace page when redefining the full page structure.
alter page Module.PageName {
operation1;
operation2;
...
};
alter snippet Module.SnippetName {
operation1;
operation2;
...
};
Multiple operations can be combined in a single ALTER statement. They are applied sequentially.
-- Single property
set caption = 'New Caption' on widgetName
-- Multiple properties
set (caption = 'Save & Close', buttonstyle = success) on btnSave
-- Page-level property (no ON clause)
set title = 'New Page Title'
Supported SET properties:
| Property | Widget Types | Value Type | Example |
|---|---|---|---|
caption | ACTIONBUTTON, LINKBUTTON | String | set caption = 'Submit' on btnSave |
content | DYNAMICTEXT | String | set content = 'New Heading' on txtTitle |
label | TEXTBOX, TEXTAREA, DATEPICKER, COMBOBOX, CHECKBOX, RADIOBUTTONS | String | set label = 'full Name' on txtName |
buttonstyle | ACTIONBUTTON, LINKBUTTON | Primary, Default, Success, Danger, Warning, Info | set buttonstyle = danger on btnDelete |
class | Any widget | CSS class string | set class = 'card mx-2' on container1 |
style | Any widget (see warning below) | Inline CSS string | set style = 'padding: 16px;' on container1 |
editable | Input widgets | String | set editable = 'Never' on txtReadOnly |
visible | Any widget | String or Boolean | set visible = false on txtHidden |
Name | Any widget | String | set Name = 'newName' on oldName |
title | Page-level only | String | set title = 'Edit Customer' |
layout | Page-level only | Qualified name | set layout = Atlas_Core.Atlas_Default |
'quotedProp' | Pluggable widgets | String, Boolean, Number | set 'showLabel' = false on cbStatus |
Pluggable widget properties use quoted names to set values in the widget's Object.Properties[]. Boolean values are stored as "yes"/"no" in BSON.
Warning: Style on DYNAMICTEXT — Setting
styledirectly on a DYNAMICTEXT widget crashes MxBuild with a NullReferenceException. Wrap the DYNAMICTEXT in a CONTAINER and apply styling to the container instead:-- Wrong: crashes MxBuild SET Style = 'color: red;' ON txtHeading -- Correct: style the container REPLACE txtHeading WITH { CONTAINER ctnHeading (Style: 'color: red;') { DYNAMICTEXT txtHeading (Content: 'Heading', RenderMode: H2) } }
-- Insert after a widget
insert after txtName {
textbox txtMiddleName (label: 'Middle Name', attribute: MiddleName)
}
-- Insert before a widget
insert before btnSave {
actionbutton btnPreview (caption: 'Preview', action: microflow Module.ACT_Preview)
}
Inserted widgets use the same syntax as create page. Multiple widgets can be inserted in a single block.
-- Drop a single widget
drop widget txtUnused
-- Drop multiple widgets
drop widget txtOldField, lblOldLabel, container2
Removes widgets and their entire subtree from the page.
-- Replace a single widget with new content
replace footer1 with {
footer newFooter {
actionbutton btnSave (caption: 'Save', action: save_changes, buttonstyle: primary)
actionbutton btnCancel (caption: 'Cancel', action: cancel_changes)
}
}
Replaces the target widget with one or more new widgets. The new widgets use the same syntax as create page.
DataGrid2 columns are addressable using dotted notation: gridName.columnName. The column name is derived from the attribute short name or caption (same as shown by describe page).
-- SET a column property
set caption = 'Product SKU' on dgProducts.Code
-- DROP a column
drop widget dgProducts.OldColumn
-- INSERT a column after an existing one
insert after dgProducts.Price {
column Margin (attribute: Margin, caption: 'Margin')
}
-- REPLACE a column
replace dgProducts.Description with {
column Notes (attribute: Notes, caption: 'Notes')
}
To discover column names, run describe page Module.PageName and look at the COLUMN names inside the DATAGRID.
add variables $showStockColumn: boolean = 'true'
Adds a new page variable (Forms$LocalVariable) to the page/snippet. DataType can be boolean, string, integer, decimal, datetime, or an entity type. Default value is a Mendix expression in single quotes.
drop variables $showStockColumn
Removes a page variable by name.
-- Auto-map placeholders by name (most common case)
set layout = Atlas_Core.Atlas_Default
-- Explicit mapping when placeholder names differ
set layout = Atlas_Core.Atlas_SideBar map (Main as content, Extra as Sidebar)
Changes the page's layout without rebuilding the widget tree. Only rewrites the FormCall.Form and FormCall.Arguments[].Parameter BSON fields — all widget content is preserved. Not supported for snippets.
When placeholders have the same names in both layouts (e.g., both have Main), auto-mapping works. Use map when placeholder names differ between the old and new layout.
alter page MyModule.Customer_Edit {
set (caption = 'Save & Close', buttonstyle = success) on btnSave
};
alter page MyModule.Customer_Edit {
insert after txtEmail {
textbox txtPhone (label: 'Phone', attribute: Phone)
}
};
alter page MyModule.ProductOverview {
add variables $showStockColumn: boolean = 'if (3 < 4) then true else false'
};
alter page MyModule.Customer_Edit {
set title = 'Edit Customer Details';
drop widget txtLegacyField, lblOldNote;
set label = 'Email Address' on txtEmail
};
alter page MyModule.Customer_Edit {
replace footer1 with {
footer newFooter {
actionbutton btnSave (caption: 'Save', action: save_changes, buttonstyle: success)
actionbutton btnDelete (caption: 'Delete', action: delete, buttonstyle: danger)
actionbutton btnCancel (caption: 'Cancel', action: cancel_changes)
}
}
};
alter snippet MyModule.NavigationMenu {
set caption = 'Dashboard' on btnHome;
insert after btnHome {
actionbutton btnReports (caption: 'Reports', action: show_page MyModule.Reports_Overview)
}
};
alter page MyModule.Customer_Edit {
set 'showLabel' = false on cbStatus;
set 'labelWidth' = 4 on cbCategory
};
<common_mistakes>
| Mistake | Fix |
|---|---|
Missing on widgetName for widget SET | Add on widgetName (only page-level Title omits ON) |
| Using unquoted pluggable property names | Quote pluggable props: set 'showLabel' = false on cb |
| Wrong widget name | Use describe page Module.Name to see widget names |
| SET on non-existent widget | Widget names are case-sensitive; check with DESCRIBE |
| Missing semicolons between operations | Each operation inside { } ends with ; |
</common_mistakes>
<validation_checklist>
describe page Module.PageName to see all widget namesmxcli check script.mdlmxcli check script.mdl -p app.mpr --referencesdescribe page Module.PageName after ALTER to confirm changes~/.mxcli/mxbuild/*/modeler/mx check app.mpr (or mxcli docker check -p app.mpr)</validation_checklist>
<output_rules>Output MDL code only in code blocks. Keep explanations concise.</output_rules>