gpt4 book ai didi

java - Wicket Wizard 在 isComplete() 方法中给出错误信息;

转载 作者:行者123 更新时间:2023-12-01 11:06:19 24 4
gpt4 key购买 nike

除了 previous question ,我正在尝试自己实现带有步骤概述的 Wicket Wizard。现在的问题是,即使该步骤尚未完成,isComplete(); 似乎也会返回 true。我执行了 3 个向导步骤,然后运行以下代码:

public class MainWizard extends Wizard{
private static final long serialVersionUID = 1L;
private List<IWizardStep> steps = new ArrayList<IWizardStep>();
private Component overview = newOverviewBar("overview");
private IWizardModel wizardModel;

public MainWizard(String id, IWizardModel wizardModel, boolean addDefaultCssStyle) {
super(id, wizardModel, addDefaultCssStyle);
this.wizardModel = wizardModel;
fillList();
getIndex();
this.add(overview);
}

public void getIndex(){
for(IWizardStep step : steps){
System.out.println(step.getClass());
if(step.equals(wizardModel.getActiveStep())){
System.out.println("Active");
} else if(!step.isComplete()){
System.out.println("Pending");
} else if(step.isComplete()){
System.out.println("Finished");
}
}
}

public void fillList(){
Iterator<IWizardStep> iterator = wizardModel.stepIterator();
while(iterator.hasNext()){
steps.add(iterator.next());
}
}

@Override
public void onActiveStepChanged(IWizardStep newStep) {
try{
getIndex();
} catch (Exception e){
e.getMessage();
}
super.onActiveStepChanged(newStep);
}
}

第一步控制台的输出是:

class {package}.StepOne > Active
class {package}.StepTwo > Finished
class {package}.StepThree > Finished

更改到下一步:

class {package}.StepOne > Finished
class {package}.StepTwo > Active
class {package}.StepThree > Finished

最后一步:

class {package}.StepOne > Finished
class {package}.StepTwo > Finished
class {package}.StepThree > Active

我无法解释这种行为。正如我在上面链接的帖子中建议的那样,如果它最终有效,我想分享这个组件。提前致谢。

我实现的步骤还没有真正的目标,这是一个问题吗?我是否必须手动设置 setComplete(); 或面板代码中的任何内容?

最佳答案

IWizardStep#isComplete()的含义不是你想象的那样:

/**
* Checks if this step is complete. This method should return {@code true} if the wizard can
* proceed to the next step.
*
* @return {@code true} if the wizard can proceed from this step, {@code false} otherwise.
*/
boolean isComplete();

记下“向导是否可以继续下一步”。

关于java - Wicket Wizard 在 isComplete() 方法中给出错误信息;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32909817/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com