Search code examples
sapui5wizard

SAPUI5 how to make sap.m.Wizard handles more than 8 Steps


Is there please any way to make the sap.m.Wizard be able to handle more than 8 Steps or is there any alternative to this control? Actually it does not shows the others Steps when I put more than 8.

thank you very much for any tip.

Regards

Aline


Solution

  • I just checked the source code of the sap.m.Wizard: https://github.com/SAP/openui5/blob/master/src/sap.m/src/sap/m/Wizard.js

    There is a constant that limits the number of steps to 8 (as you've already found out).

    This constant is used in the method Wizard.prototype._isMaxStepCountExceeded. This method is then used in Wizard.prototype.addStep.

    I see 3 possibilities. 2 of them include subclassing the Wizard:

    • Override the constant Wizard.CONSTANTS.MAXIMUM_STEPS in your subclass to a value greater than 8.
    • Override the addStep method in your subclass so unlimited steps are possible.
    • If branching is enabled, the Wizard ignores the constant MAXIMUM_STEPS. But this does not seem like a good solution to me, because it would require changing each WizardStep in your XML.

    Edit: Here is a complete subclassing example

    sap.ui.define([
        "sap/m/Wizard"
    ], function(Wizard) {
        "use strict";
    
        return Wizard.extend("mynamespace.InfiniteWizard", {
    
            renderer: {},
    
            addStep: function (wizardStep) {
                this._incrementStepCount();
                return this.addAggregation("steps", wizardStep);
            }
        });
    });