1 /** 2 * Copyright 2005-2014 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.uif.lifecycle; 17 18 import java.util.Set; 19 20 import org.kuali.rice.krad.uif.UifConstants; 21 import org.kuali.rice.krad.uif.lifecycle.ViewLifecycle.LifecycleEvent; 22 import org.kuali.rice.krad.uif.util.LifecycleElement; 23 24 /** 25 * Lifecycle phase processing task for applying the model to a component. 26 * 27 * <p> 28 * During the apply model phase each component of the tree if invoked to setup any state based on 29 * the given model data 30 * </p> 31 * 32 * <p> 33 * Part of the view lifecycle that applies the model data to the view. Should be called after the 34 * model has been populated before the view is rendered. The main things that occur during this 35 * phase are: 36 * <ul> 37 * <li>Generation of dynamic fields (such as collection rows)</li> 38 * <li>Execution of conditional logic (hidden, read-only, required settings based on model values)</li> 39 * </ul> 40 * </p> 41 * 42 * <p> 43 * The update phase can be called multiple times for the view's lifecycle (typically only once per 44 * request) 45 * </p> 46 * 47 * @author Kuali Rice Team (rice.collab@kuali.org) 48 */ 49 public class ApplyModelComponentPhase extends ViewLifecyclePhaseBase { 50 51 /** 52 * {@inheritDoc} 53 */ 54 @Override 55 public String getViewPhase() { 56 return UifConstants.ViewPhases.APPLY_MODEL; 57 } 58 59 /** 60 * {@inheritDoc} 61 */ 62 @Override 63 public String getStartViewStatus() { 64 return UifConstants.ViewStatus.INITIALIZED; 65 } 66 67 /** 68 * {@inheritDoc} 69 */ 70 @Override 71 public String getEndViewStatus() { 72 return UifConstants.ViewStatus.MODEL_APPLIED; 73 } 74 75 /** 76 * {@inheritDoc} 77 */ 78 @Override 79 public LifecycleEvent getEventToNotify() { 80 return null; 81 } 82 83 /** 84 * Visit a lifecycle element. 85 * 86 * @param element The lifecycle element (component or layout manager) to mark as visisted. 87 * @return True if the element has been visited before, false if this was the first visit. 88 */ 89 public boolean visit(LifecycleElement element) { 90 Set<String> visitedIds = ViewLifecycle.getVisitedIds(); 91 if (visitedIds.contains(element.getId())) { 92 return true; 93 } 94 95 synchronized (visitedIds) { 96 return !visitedIds.add(element.getId()); 97 } 98 } 99 100 }