View Javadoc

1   /**
2    * Copyright 2005-2013 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.util;
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.uif.component.Component;
21  import org.kuali.rice.krad.uif.element.ContentElementBase;
22  import org.kuali.rice.krad.uif.view.View;
23  
24  import java.util.ArrayList;
25  import java.util.HashMap;
26  import java.util.List;
27  import java.util.Map;
28  
29  /**
30   * BreadcrumbItem represents a single item in the breadcrumb list that is generated by the breadcrumbs widget
31   */
32  @BeanTag(name = "breadcrumbItem-bean", parent = "Uif-BreadcrumbItem")
33  public class BreadcrumbItem extends ContentElementBase {
34      private String label;
35      private UrlInfo url;
36      private Component siblingBreadcrumbComponent;
37      private boolean renderAsLink;
38  
39      /**
40       * The following updates are done here:
41       *
42       * <ul>
43       * <li>Evaluate expressions on url object</li>
44       * </ul>
45       *
46       * @see org.kuali.rice.krad.uif.component.Component#performApplyModel(org.kuali.rice.krad.uif.view.View,
47       *      java.lang.Object, org.kuali.rice.krad.uif.component.Component)
48       */
49      @Override
50      public void performApplyModel(View view, Object model, Component parent) {
51          super.performApplyModel(view, model, parent);
52  
53          if (url != null) {
54              Map<String, Object> context = new HashMap<String, Object>();
55              context.putAll(view.getContext());
56  
57              ExpressionUtils.populatePropertyExpressionsFromGraph(url, false);
58              view.getViewHelperService().getExpressionEvaluator().evaluateExpressionsOnConfigurable(view, url,
59                      context);
60          }
61      }
62  
63      /**
64       * Adds siblingBreadcrumbComponent to the components for the lifecycle
65       *
66       * @see org.kuali.rice.krad.uif.component.Component#getComponentsForLifecycle()
67       */
68      @Override
69      public List<Component> getComponentsForLifecycle() {
70          List<Component> components = new ArrayList<Component>();
71  
72          components.add(siblingBreadcrumbComponent);
73          components.addAll(super.getComponentsForLifecycle());
74  
75          return components;
76      }
77  
78      /**
79       * The label for this breadcrumbItem.  The label is the textual content that will be displayed for the breadcrumb.
80       *
81       * @return the label
82       */
83      @BeanTagAttribute(name = "label")
84      public String getLabel() {
85          return label;
86      }
87  
88      /**
89       * Set the label for this breadcrumbItem.  The label is the textual content that will be displayed for the
90       * breadcrumb.
91       *
92       * @param label
93       */
94      public void setLabel(String label) {
95          this.label = label;
96      }
97  
98      /**
99       * The url used for the breadcrumb link represented by this item
100      *
101      * @return the url object
102      */
103     @BeanTagAttribute(name = "url")
104     public UrlInfo getUrl() {
105         return url;
106     }
107 
108     /**
109      * Set the url object
110      *
111      * @param urlObject
112      */
113     public void setUrl(UrlInfo urlObject) {
114         this.url = urlObject;
115     }
116 
117     /**
118      * Set the breadcrumb component for this breadcrumbs sibling content/navigation.  This content will appear in
119      * a pop-up menu.
120      *
121      * @return the sibling component to appear in a popup menu
122      */
123     @BeanTagAttribute(name = "siblingBreadcrumbComponent", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
124     public Component getSiblingBreadcrumbComponent() {
125         return siblingBreadcrumbComponent;
126     }
127 
128     /**
129      * Set the sibling breadcrumb component
130      *
131      * @param siblingBreadcrumbComponent
132      */
133     public void setSiblingBreadcrumbComponent(Component siblingBreadcrumbComponent) {
134         this.siblingBreadcrumbComponent = siblingBreadcrumbComponent;
135     }
136 
137     /**
138      * If true, the breadcrumbItem will render as a link, otherwise it will render as a span (not-clickable).
139      * By default, the last BreadcrumbItem in the list will ALWAYS render as span regardless of this property's value.
140      *
141      * @return true if rendering as a link, false otherwise
142      */
143     @BeanTagAttribute(name = "renderAsLink")
144     public boolean isRenderAsLink() {
145         return renderAsLink;
146     }
147 
148     /**
149      * Set to true to render as a link, false otherwise
150      *
151      * @param renderAsLink
152      */
153     public void setRenderAsLink(boolean renderAsLink) {
154         this.renderAsLink = renderAsLink;
155     }
156 }