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