Matt Jensen-2 wrote:
> 
> I have a use case where I would like to be able to splice wizard 
> sequences together, possibly injecting one wizard into another under 
> certain conditions. 
> 

Try using the attached RecursiveWizardModel. You give it a wizard model and
it 
is prepared to handle a step returned from that model which is a child
wizard 
model. The child wizard model is completely unaware of the enclosing model.

Some sample code:

public class RecursiveWizardTest extends WebPage {
        private MyStep stepA;
        private MyStep stepB;
        private MyStep stepC;
        private MyDynamicStep stepX;
        private MyDynamicStep stepY;
        private MyDynamicStep stepZ;
        private WizardModel secondLevelModel;
        private MyDynamicStep stepGroup;
        
        
        public RecursiveWizardTest() {
                stepA = new MyStep("a");
                stepB = new MyStep("b");
                stepC = new MyStep("c");
                secondLevelModel = new WizardModel();
                secondLevelModel.add(stepA);
                secondLevelModel.add(stepB);
                secondLevelModel.add(stepC);
                stepX = new MyDynamicStep(null, "x");
                stepY = new MyDynamicStep(stepX, "y");
                stepGroup = new MyDynamicStep(stepY, "unused") {
                                        public IWizardModel getWizardModel() {
                                                return secondLevelModel;
                                        }
                                };
                stepZ = new MyDynamicStep(stepGroup, "z");
                stepX.setNextStep(stepY);
                stepY.setNextStep(stepGroup);
                stepGroup.setNextStep(stepZ);
                DynamicWizardModel topLevelModel = new 
DynamicWizardModel(stepX);
                topLevelModel.addListener(new IWizardModelListener() {
                        public void onFinish() {
                                setResponsePage(Completed.class);
                        }
                        public void onCancel() {
                        }
                        public void onActiveStepChanged(IWizardStep newStep) {
                        }
                });
                Wizard w = new Wizard("w", new 
RecursiveWizardModel(topLevelModel));
                add(w);
        }
}

public class MyStep extends WizardStep {
        public MyStep(String label) {
                add(new Label("label", label));
        }
}

public class MyDynamicStep extends DynamicWizardStep implements
IWizardStepGroup {
        private IDynamicWizardStep nextStep;

        public MyDynamicStep(IDynamicWizardStep previousStep, String label) {
                super(previousStep);
                add(new Label("label", label));
        }
        public boolean isNextAvailable() {
                return nextStep != null;
        }
        public IDynamicWizardStep next() {
                return nextStep;
        }
        public void setNextStep(IDynamicWizardStep nextStep) {
                this.nextStep = nextStep;
        }
        public boolean isLastStep() {
                return nextStep != null;
        }
        public IWizardModel getWizardModel() {
                return null;
        }
}

http://www.nabble.com/file/p12898519/RecursiveWizardModel.java
RecursiveWizardModel.java 
-- 
View this message in context: 
http://www.nabble.com/Nestable-Wizard-Models-tf4516623.html#a12898519
Sent from the Wicket - Dev mailing list archive at Nabble.com.

Reply via email to