2015-10-02 22 views
0

除了previous question之外,我正嘗試通過一個步驟概述來執行我自己的Wicket Wizard實現。現在的問題是,即使步驟尚未完成,isComplete();似乎也會返回true。我提出3 wizardsteps,然後我運行這樣的代碼:Wicket嚮導在方法isComplete()中給出了錯誤信息;

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); 
    } 
} 

在控制檯輸出的第一個步驟是:

類{包} .StepOne>有源
類{包} .StepTwo>成品
類{包} .StepThree>成品

在轉換到下一個步驟:

類{包} .StepOne>成品
類{包} .StepTwo>有源
類{包} .StepThree>成品

在最後步驟:

class {package} .StepOne> Finished
class {package} .StepTwo> Finished
class {package} .StepThree> Activ e

我無法解釋這種行爲。正如在上面提到的我鏈接的帖子中所提到的,如果它在最後工作,我想分享這個組件。提前致謝。

這是一個問題,我執行的步驟沒有一個真正的目標呢?我是否必須手動設置setComplete();或者它在我的代碼中的面板?

回答

1

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(); 

注意到「如果該向導可以進行下一個步驟」。

+0

好吧,這意味着我必須通過** setComplete(); **手動告訴待處理或完成的步驟 –