View Javadoc
1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.krad.labs;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.kuali.rice.krad.uif.component.Component;
22  import org.kuali.rice.krad.uif.container.GroupBase;
23  import org.kuali.rice.krad.uif.util.LifecycleElement;
24  import org.kuali.rice.krad.web.form.UifFormBase;
25  
26  public class WizardGroup extends GroupBase {
27  
28      @Override
29      public void performApplyModel(Object model, LifecycleElement parent) {
30          UifFormBase form = (UifFormBase) model;
31  
32          String stepStr = form.getActionParameters().get(this.getId()+".step");
33          Integer step = 0;
34  
35          if (stepStr != null && stepStr.matches("\\d")) {
36              step = Integer.valueOf(stepStr);
37          }
38  
39          List<Component> currentItems = new ArrayList<Component>();
40          for (int i = 0, len = getItems().size(); i < len; i++) {
41              Component component = getItems().get(i);
42  
43              if (i == step) {
44                  currentItems.add(component);
45              }
46          }
47  
48          setItems(currentItems);
49  
50          super.performApplyModel(model, parent);
51      }
52  }