Fix Deprecated Controls

作者 UI52b8c4a944e39无许可证收录于 2026年10月8日更新于 2026年10月8日

Fix deprecated control/class/interface/type issues that UI5 linter reports but cannot auto-fix. Use this skill when linter outputs: - `no-deprecated-api` with messages about deprecated class, interface, type, property, or property of class - Messages like "Use of deprecated class '...'", "Use of deprecated interface '...'", "Use of deprecated property '...'" Trigger on: deprecated control usage in JS `new` expressions, deprecated properties in constructor settings, deprecated interfaces/types in metadata, deprecated controls/properties in XML views, sap.m.MessagePage modernization to IllustratedMessage. Use this skill whenever you see 'deprecated class', 'deprecated property', 'deprecated interface', or 'deprecated type' in linter output, even if the user doesn't explicitly mention deprecation. Provides replacement guidance for deprecated UI5 controls and their properties.

AI 生成的概览

修复 UI5 linter 报告但无法自动修复的已弃用控件、类、接口、类型和属性。

功能
针对 no-deprecated-api 规则报告的已弃用 UI5 API 提供替换指引,涵盖 new 表达式中的已弃用类、构造函数中的已弃用属性、元数据中的已弃用接口和类型,以及 XML 视图中的已弃用控件和属性。文档包含 sap.ui.commons、sap.ui.ux3、sap.m、sap.f、sap.ui.table、sap.ui.unified、sap.ui.layout、sap.ui.comp 和 sap.ui.mdc 的替换对照表,并单列 MessagePage 迁移到 IllustratedMessage、VariantManagement 迁移等章节。它还要求对 p13n 和个性化控件只报告、不自动改造,交由人工处理。
适用场景
当 UI5 linter 输出包含 no-deprecated-api 的已弃用类、属性、接口或类型提示时使用,也适用于在 JavaScript 和 XML 视图中改造已弃用控件。还可用于 MessagePage 到 IllustratedMessage、VariantManagement 的迁移。不适用于部分弃用的 API 签名或表格行模式属性,这些有单独的技能处理。
运行要求
需要可通过 npx 运行的 UI5 linter(@ui5/linter),以及 UI5 API 参考文档的访问能力,可选通过 UI5 MCP Server 的 get_api_reference 工具获取。不附带脚本,仅为说明文档,另有一份参考文档。

Fix Deprecated Controls, Classes, Interfaces, and Types

This skill fixes deprecated control/class/interface/type issues that the UI5 linter detects but cannot auto-fix because they require understanding the specific replacement APIs.

Linter Rules Handled

Rule IDMessage PatternThis Skill's Action
no-deprecated-apiUse of deprecated class '...'Replace with new class
no-deprecated-apiUse of deprecated interface '...'Replace with new interface
no-deprecated-apiUse of deprecated type '...'Replace with new type
no-deprecated-apiUse of deprecated property '...'Remove or replace property
no-deprecated-apiUse of deprecated property '...' of class '...'Replace with new property/API

When to Use

Apply this skill when you see linter output like:

MyController.js:15:5 error Use of deprecated class 'sap.ui.commons.Button'  no-deprecated-apiMyController.js:20:5 error Use of deprecated property 'blocked' of class 'sap.m.Button'  no-deprecated-apiMyView.view.xml:10:5 error Use of deprecated class 'sap.m.DateTimeInput'  no-deprecated-apiComponent.js:25:5 error Use of deprecated interface 'sap.ui.core.IFormContent'  no-deprecated-api

Getting Replacement Information

Run the linter with --details flag to get links to API documentation with replacement guidance:

bash
npx @ui5/linter --details

Use the UI5 MCP Server's get_api_reference tool to check deprecation status and find replacements:

  • Query: sap.ui.commons.Button or sap.m.Button#blocked

Fix Strategy

1. Deprecated Class in new Expression

Problem: Using a deprecated control class.

javascript
// Before - triggers no-deprecated-apisap.ui.define([    "sap/ui/core/mvc/Controller",    "sap/ui/commons/Button"  // Deprecated library!], function(Controller, Button) {    "use strict";
    return Controller.extend("my.app.controller.Main", {        onInit: function() {            var oButton = new Button({                text: "Click me"            });        }    });});

Fix Strategy: Replace with the modern equivalent class.

javascript
// After - use sap.m.Button insteadsap.ui.define([    "sap/ui/core/mvc/Controller",    "sap/m/Button"], function(Controller, Button) {    "use strict";
    return Controller.extend("my.app.controller.Main", {        onInit: function() {            var oButton = new Button({                text: "Click me"            });        }    });});

Common Deprecated Class Replacements:

Deprecated ClassReplacement
sap.ui.commons.*sap.m.* equivalents
sap.ui.ux3.*sap.m.* or sap.f.*
sap.ui.commons.TextFieldsap.m.Input
sap.ui.commons.Buttonsap.m.Button
sap.ui.commons.Labelsap.m.Label
sap.ui.commons.CheckBoxsap.m.CheckBox
sap.ui.commons.DropdownBoxsap.m.Select or sap.m.ComboBox
sap.ui.model.odata.ODataModelsap.ui.model.odata.v2.ODataModel
sap.m.MessagePagesap.m.IllustratedMessage (see section 8)
sap.viz.ui5.controls.VizFrame (old)Check sap.viz documentation

sap.m Deprecated Controls:

Deprecated ClassReplacementNotes
sap.m.UploadCollectionsap.m.upload.UploadSet or sap.m.plugins.UploadSetwithTableUploadSetwithTable for table-based layouts
sap.m.TablePersoDialogsap.m.p13n.*Do not auto-modernize — report for manual modernization
sap.m.TablePersoControllersap.m.p13n.*Do not auto-modernize — report for manual modernization
sap.m.TablePersoProvidersap.m.p13n.*Do not auto-modernize — report for manual modernization
sap.m.P13nDialogsap.m.p13n.PopupDo not auto-modernize — report for manual modernization
sap.m.P13nColumnsPanelsap.m.p13n.SelectionPanelDo not auto-modernize — report for manual modernization
sap.m.P13nSortPanelsap.m.p13n.SortPanelDo not auto-modernize — report for manual modernization
sap.m.P13nGroupPanelsap.m.p13n.GroupPanelDo not auto-modernize — report for manual modernization
sap.m.P13nFilterPanelsap.m.p13n.FilterPanelDo not auto-modernize — report for manual modernization
sap.m.DateTimeInputsap.m.DatePicker + sap.m.TimePickerSplit into separate controls
sap.m.MultiEditField—No direct replacement, custom implementation required
sap.m.RouteMatchedHandlersap.m.routing.RouteMatchedHandlerUse the routing module

sap.f Deprecated Controls:

Deprecated ClassReplacementNotes
sap.f.Avatarsap.m.AvatarMoved to sap.m
sap.f.IllustratedMessagesap.m.IllustratedMessageMoved to sap.m
sap.f.Illustrationsap.m.IllustrationMoved to sap.m

sap.ui.table Deprecated Controls:

Deprecated ClassReplacementNotes
sap.ui.table.ColumnMenusap.m.table.columnmenu.MenuNew column menu framework
sap.ui.table.AnalyticalColumnMenusap.m.table.columnmenu.MenuNew column menu framework
sap.ui.table.TablePersoControllersap.m.p13n.*Do not auto-modernize — report for manual modernization

sap.ui.unified Deprecated Controls:

Deprecated ClassReplacementNotes
sap.ui.unified.Shell—No replacement — redesign using sap.f.ShellBar or sap.tnt.ToolPage
sap.ui.unified.ShellOverlay—No replacement
sap.ui.unified.ShellLayout—No replacement
sap.ui.unified.SplitContainersap.m.SplitContainer or sap.f.FlexibleColumnLayoutUse responsive layout
sap.ui.unified.ContentSwitcher—No replacement — use NavContainer or custom logic

sap.ui.layout Deprecated Controls:

Deprecated ClassReplacementNotes
sap.ui.layout.form.GridLayoutsap.ui.layout.form.ColumnLayout or sap.ui.layout.form.ResponsiveGridLayoutGridLayout was removed

sap.ui.comp Deprecated Controls:

Deprecated ClassReplacementNotes
sap.ui.comp.variants.VariantManagementsap.m.VariantManagementSee section 9 for property mapping

sap.ui.mdc Deprecated/Changed APIs:

DeprecatedReplacementNotes
sap.ui.mdc.enum.* enumssap.ui.mdc.enums.*Namespace renamed (enum → enums)
sap.ui.mdc.FilterBar old APIsap.ui.mdc.FilterBar refactoredCheck API for changed properties
sap.ui.mdc.Link FLP integrationDecoupled from FLPCheck new API for direct usage

2. Deprecated Property in Constructor

Problem: Using a deprecated property when creating a control.

javascript
// Before - 'blocked' property is deprecatedsap.ui.define([    "sap/ui/core/mvc/Controller",    "sap/m/Button"], function(Controller, Button) {    "use strict";
    return Controller.extend("my.app.controller.Main", {        onInit: function() {            var oButton = new Button({                text: "Submit",                blocked: true  // Deprecated!            });        }    });});

Fix Strategy: Use the replacement property or API.

javascript
// After - use 'enabled' insteadsap.ui.define([    "sap/ui/core/mvc/Controller",    "sap/m/Button"], function(Controller, Button) {    "use strict";
    return Controller.extend("my.app.controller.Main", {        onInit: function() {            var oButton = new Button({                text: "Submit",                enabled: false  // Use enabled: false instead of blocked: true            });        }    });});

Common Deprecated Property Replacements:

ControlDeprecated PropertyReplacement
sap.m.Buttonblockedenabled (inverted logic)
sap.m.Buttontap (event)press
sap.ui.table.TablevisibleRowCountModerowMode aggregation
sap.ui.table.TablevisibleRowCountrowMode aggregation
sap.ui.table.TablefixedRowCountrowMode aggregation
sap.ui.comp.smarttable.SmartTableuseExportToExcelenableExport
sap.ui.layout.form.SimpleFormminWidthRemove (only for ResponsiveLayout)

3. Deprecated Interface in Metadata

Problem: Using a deprecated interface in control/component metadata.

javascript
// Before - deprecated interfacesap.ui.define([    "sap/ui/core/Control"], function(Control) {    "use strict";
    return Control.extend("my.app.control.MyControl", {        metadata: {            interfaces: ["sap.ui.core.IFormContent"]  // Check if deprecated        }    });});

Fix Strategy: Replace with the current interface or remove if no longer needed.

javascript
// After - use current interfacesap.ui.define([    "sap/ui/core/Control"], function(Control) {    "use strict";
    return Control.extend("my.app.control.MyControl", {        metadata: {            interfaces: ["sap.ui.core.ISemanticFormContent"]  // Updated interface        }    });});

4. Deprecated Type in Metadata

Problem: Using a deprecated type in property definition.

javascript
// Before - deprecated typemetadata: {    properties: {        size: { type: "sap.ui.core.CSSSize" }  // May be deprecated    }}

Fix Strategy: Check the API reference and use the current type.

5. Deprecated Controls in XML Views

Problem: Using deprecated controls in XML views.

xml
<!-- Before - DateTimeInput is deprecated --><mvc:View    xmlns:mvc="sap.ui.core.mvc"    xmlns="sap.m">    <DateTimeInput value="{/date}" /></mvc:View>

Fix Strategy: Replace with the modern equivalent controls.

xml
<!-- After - use DatePicker and TimePicker --><mvc:View    xmlns:mvc="sap.ui.core.mvc"    xmlns="sap.m">    <DatePicker value="{/date}" />    <TimePicker value="{/time}" /></mvc:View>

6. Deprecated Properties in XML Views

Problem: Using deprecated properties on controls in XML.

xml
<!-- Before - blocked property deprecated --><Button text="Submit" blocked="true" />

Fix Strategy: Replace with the current property.

xml
<!-- After - use enabled with inverted logic --><Button text="Submit" enabled="false" />

7. Deprecated Aggregations in XML Views

Problem: Using deprecated aggregations.

xml
<!-- Before - plugins aggregation may be deprecated in some contexts --><table:Table>    <table:plugins>        <table:MultiSelectionPlugin />    </table:plugins></table:Table>

Fix Strategy: Check API reference for the current aggregation name or approach.

8. sap.m.MessagePage → sap.m.IllustratedMessage

sap.m.MessagePage is deprecated in favor of sap.m.IllustratedMessage. Key changes: text+description → single description, icon → illustrationType enum, showNavButton/navButtonPress → Button in additionalContent aggregation.

For the full property mapping table, XML/JS examples, and illustration type list, read references/control-modernization-details.md.

9. sap.ui.comp.variants.VariantManagement → sap.m.VariantManagement

Key changes: variantItems → items, VariantItem.text → .title, showExecuteOnSelection → supportApplyAutomatically, showShare → supportPublic. The standard variant must be explicitly created with rename="false" and remove="false".

For the full property mapping table and standard variant XML example, read references/control-modernization-details.md.

10. Deprecated Core Classes

Key replacements: MessageManager → sap/ui/core/Messaging, Export* → sap/ui/export/Spreadsheet, LocalBusyIndicator → Control.setBusy(true). SearchProvider, OpenSearchProvider, and ScrollBar have no replacement.

For the full table and MessageManager→Messaging code example, read references/control-modernization-details.md.

Implementation Steps

  1. Run linter with --details to get replacement documentation links:

    bash
    npx @ui5/linter --details
  2. Identify the deprecated item from the error message (class, property, interface, type)

  3. Check if this is a p13n/personalization control — if the deprecated class is any of:

    • sap.m.P13nDialog, sap.m.P13nColumnsPanel, sap.m.P13nSortPanel, sap.m.P13nGroupPanel, sap.m.P13nFilterPanel
    • sap.m.TablePersoDialog, sap.m.TablePersoController, sap.m.TablePersoProvider
    • sap.ui.table.TablePersoController

    Do NOT attempt to auto-modernize these. The p13n framework modernization requires significant architectural changes (different initialization patterns, state persistence models, and panel configurations) that cannot be reliably automated. Instead, report them to the user:

    ⚠️ Manual modernization required: <ClassName> at <file>:<line>Replacement: sap.m.p13n.* frameworkReason: p13n modernization requires architectural changes — see UI5 documentation for sap.m.p13n
  4. Look up the replacement (for non-p13n controls) in:

    • The details link from npx @ui5/linter --details
    • UI5 API Reference using the get_api_reference tool
    • The deprecation tables above
  5. Apply the fix:

    • For classes: Change import and class name
    • For properties: Change property name or use new API
    • For interfaces/types: Update metadata
    • For XML: Update element names and attributes
  6. Verify by re-running the linter

Example Fix Session

Given linter output:

npx @ui5/linter --details
MyController.js:15:5 error Use of deprecated class 'sap.m.DateTimeInput'  no-deprecated-api  Details: {@link sap.m.DateTimeInput}MyController.js:25:5 error Use of deprecated property 'blocked' of class 'sap.m.Button'  no-deprecated-api  Details: {@link sap.m.Button#blocked}

Before:

javascript
sap.ui.define([    "sap/ui/core/mvc/Controller",    "sap/m/DateTimeInput",    "sap/m/Button"], function(Controller, DateTimeInput, Button) {    "use strict";
    return Controller.extend("my.app.controller.Main", {        onInit: function() {            var oDateTimeInput = new DateTimeInput({                value: "{/date}"            });
            var oButton = new Button({                text: "Submit",                blocked: true            });        }    });});

After:

javascript
sap.ui.define([    "sap/ui/core/mvc/Controller",    "sap/m/DatePicker",    "sap/m/TimePicker",    "sap/m/Button"], function(Controller, DatePicker, TimePicker, Button) {    "use strict";
    return Controller.extend("my.app.controller.Main", {        onInit: function() {            // DateTimeInput replaced with separate DatePicker and TimePicker            var oDatePicker = new DatePicker({                value: "{/date}"            });            var oTimePicker = new TimePicker({                value: "{/time}"            });
            var oButton = new Button({                text: "Submit",                enabled: false  // blocked: true → enabled: false            });        }    });});

Notes

  • Always check the UI5 API Reference for the specific replacement guidance
  • Some deprecated controls may have multiple possible replacements depending on your use case
  • When replacing deprecated libraries (sap.ui.commons, sap.ui.ux3), the replacement controls may have different APIs
  • Property replacements may have inverted logic (e.g., blocked: true → enabled: false)
  • Consider using npx @ui5/linter --details to get direct links to modernization documentation
  • sap.f.IllustratedMessage and sap.f.Illustration are deprecated in favor of sap.m.IllustratedMessage and sap.m.Illustration — this is a simple namespace move with the same API
  • When modernizing sap.ui.comp.variants.VariantManagement, the standard variant must be explicitly created (see section 9)

Related Skills

  • fix-table-row-mode: For deprecated row-related properties on sap.ui.table.Table (visibleRowCountMode, visibleRowCount, rowHeight, etc.), use fix-table-row-mode — it handles the modernization to the rowMode aggregation
  • fix-partially-deprecated-apis: For partially deprecated API signatures (e.g., Parameters.get, View.create), use fix-partially-deprecated-apis instead of this skill

来源与署名

来源:UI5/plugins-coding-agents位于plugins/ui5-modernization/skills/fix-deprecated-controls提交2b8c4a9

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架