View Javadoc
1   /**
2    * Copyright 2005-2016 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.layout;
17  
18  import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19  import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20  import org.kuali.rice.krad.datadictionary.parse.BeanTags;
21  import org.kuali.rice.krad.uif.component.Component;
22  import org.kuali.rice.krad.uif.component.ListAware;
23  import org.kuali.rice.krad.uif.container.Group;
24  import org.kuali.rice.krad.uif.util.LifecycleElement;
25  
26  /**
27   * List layout manager is a layout manager for group types to output their items as either ordered or
28   * unordered lists.
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  @BeanTags({@BeanTag(name = "listLayout", parent = "Uif-ListLayout"),
33          @BeanTag(name = "orderedListLayout", parent = "Uif-OrderedListLayout")})
34  public class ListLayoutManager extends LayoutManagerBase {
35      private static final long serialVersionUID = -8611267646944565117L;
36  
37      private boolean orderedList;
38  
39      public ListLayoutManager() {
40          super();
41      }
42  
43      /**
44       * Iterates through the groups items and sets the rendered in list boolean.
45       *
46       * {@inheritDoc}
47       */
48      @Override
49      public void performApplyModel(Object model, LifecycleElement component) {
50          super.performApplyModel(model, component);
51  
52          Group parentGroup = (Group) component;
53  
54          for (Component item : parentGroup.getItems()) {
55              if (ListAware.class.isAssignableFrom(item.getClass())) {
56                  ((ListAware) item).setRenderedInList(true);
57              }
58          }
59      }
60  
61      /**
62       * If true, this list layout is an ordered list (ol).  Otherwise, the the layout is an unordered list (ul).
63       *
64       * @return true if orderedList, false if unordered
65       */
66      @BeanTagAttribute
67      public boolean isOrderedList() {
68          return orderedList;
69      }
70  
71      /**
72       * Setter for {@link ListLayoutManager#isOrderedList()}.
73       * @param orderedList property value
74       */
75      public void setOrderedList(boolean orderedList) {
76          this.orderedList = orderedList;
77      }
78  
79  }