001 /**
002 * Copyright 2005-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.krad.labs;
017
018 import java.util.ArrayList;
019 import java.util.List;
020
021 import org.kuali.rice.krad.uif.component.Component;
022 import org.kuali.rice.krad.uif.container.GroupBase;
023 import org.kuali.rice.krad.uif.util.LifecycleElement;
024 import org.kuali.rice.krad.web.form.UifFormBase;
025
026 public class WizardGroup extends GroupBase {
027
028 @Override
029 public void performApplyModel(Object model, LifecycleElement parent) {
030 UifFormBase form = (UifFormBase) model;
031
032 String stepStr = form.getActionParameters().get(this.getId()+".step");
033 Integer step = 0;
034
035 if (stepStr != null && stepStr.matches("\\d")) {
036 step = Integer.valueOf(stepStr);
037 }
038
039 List<Component> currentItems = new ArrayList<Component>();
040 for (int i = 0, len = getItems().size(); i < len; i++) {
041 Component component = getItems().get(i);
042
043 if (i == step) {
044 currentItems.add(component);
045 }
046 }
047
048 setItems(currentItems);
049
050 super.performApplyModel(model, parent);
051 }
052 }