Coverage Report - org.kuali.rice.kns.uif.core.Component
 
Classes in this File Line Coverage Branch Coverage Complexity
Component
N/A
N/A
1
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  * 
 4  
  * Licensed under the Educational Community License, Version 1.0 (the
 5  
  * "License"); 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/ecl1.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, WITHOUT
 12  
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 13  
  * License for the specific language governing permissions and limitations under
 14  
  * the License.
 15  
  */
 16  
 package org.kuali.rice.kns.uif.core;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.List;
 20  
 import java.util.Map;
 21  
 import java.util.Set;
 22  
 
 23  
 import org.kuali.rice.kns.uif.container.View;
 24  
 import org.kuali.rice.kns.uif.modifier.ComponentModifier;
 25  
 import org.kuali.rice.kns.uif.service.ViewHelperService;
 26  
 
 27  
 /**
 28  
  * All classes of the UIF that are used as a rendering element implement the
 29  
  * component interface. This interface defines basic properties and methods that
 30  
  * all such classes much implement. All components within the framework have the
 31  
  * following structure:
 32  
  * <ul>
 33  
  * <li>Dictionary Configuration/Composition</li>
 34  
  * <li>Java Class (the Component implementation</li>
 35  
  * <li>>JSP Template Renderer</li>
 36  
  * </ul>
 37  
  * 
 38  
  * There are three basic types of components:
 39  
  * <ul>
 40  
  * <li>Container Components: <code>View</code>, <code>Group</code></li>
 41  
  * <li>Field Components: <code>Field</code></li>
 42  
  * <li>Widget Components: <code>Widget</code></li>
 43  
  * </ul>
 44  
  * 
 45  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 46  
  * 
 47  
  * @see org.kuali.rice.kns.uif.container.Container
 48  
  * @see org.kuali.rice.kns.uif.field.Field
 49  
  * @see org.kuali.rice.kns.uif.widget.Widget
 50  
  */
 51  
 public interface Component extends Serializable, Ordered {
 52  
 
 53  
     /**
 54  
      * The unique id (within a given tree) for the component
 55  
      * 
 56  
      * <p>
 57  
      * The id will be used by renderers to set the HTML element id. This gives a
 58  
      * way to find various elements for scripting. If the id is not given, a
 59  
      * default will be generated by the framework
 60  
      * </p>
 61  
      * 
 62  
      * @return String id
 63  
      */
 64  
     public String getId();
 65  
 
 66  
     /**
 67  
      * Sets the unique id (within a given tree) for the component
 68  
      * 
 69  
      * @param id
 70  
      *            - string to set as the component id
 71  
      */
 72  
     public void setId(String id);
 73  
 
 74  
     /**
 75  
      * The name for the component type
 76  
      * 
 77  
      * <p>
 78  
      * This is used within the rendering layer to pass the component instance
 79  
      * into the template. The component instance is exported under the name
 80  
      * given by this method.
 81  
      * </p>
 82  
      * 
 83  
      * @return String type name
 84  
      */
 85  
     public String getComponentTypeName();
 86  
 
 87  
     /**
 88  
      * The path to the JSP file that should be called to render the component
 89  
      * 
 90  
      * <p>
 91  
      * The path should be relative to the web root. An attribute will be
 92  
      * available to the component to use under the name given by the method
 93  
      * <code>getComponentTypeName</code>. Based on the component type,
 94  
      * additional attributes could be available for use. See the component
 95  
      * documentation for more information on such attributes.
 96  
      * </p>
 97  
      * 
 98  
      * <p>
 99  
      * e.g. '/krad/WEB-INF/jsp/tiles/component.jsp'
 100  
      * </p>
 101  
      * 
 102  
      * @return String representing the template path
 103  
      */
 104  
     public String getTemplate();
 105  
 
 106  
     /**
 107  
      * Setter for the components template
 108  
      * 
 109  
      * @param template
 110  
      */
 111  
     public void setTemplate(String template);
 112  
 
 113  
     /**
 114  
      * A title for the component. Depending on the component can be used in
 115  
      * various ways. For example with a Container component the title is used to
 116  
      * set the header text. For components like controls other other components
 117  
      * that render an HTML element it is used to set the HTML title attribute
 118  
      * 
 119  
      * @return String title for component
 120  
      */
 121  
     public String getTitle();
 122  
 
 123  
     /**
 124  
      * Setter for the components title
 125  
      * 
 126  
      * @param title
 127  
      */
 128  
     public void setTitle(String title);
 129  
 
 130  
     /**
 131  
      * Should be called to initialize the component
 132  
      * 
 133  
      * <p>
 134  
      * Where components can set defaults and setup other necessary state. The
 135  
      * initialize method should only be called once per component lifecycle and
 136  
      * is invoked within the initialize phase of the view lifecylce.
 137  
      * </p>
 138  
      * 
 139  
      * @param view
 140  
      *            - view instance in which the component belongs
 141  
      * @see ViewHelperService#initializeComponent
 142  
      */
 143  
     public void performInitialization(View view);
 144  
 
 145  
     /**
 146  
      * Called after the initialize phase to perform conditional logic based on
 147  
      * the model data
 148  
      * 
 149  
      * <p>
 150  
      * Where components can perform conditional logic such as dynamically
 151  
      * generating new fields or setting field state based on the given data
 152  
      * </p>
 153  
      * 
 154  
      * @param view
 155  
      *            - view instance to which the component belongs
 156  
      * @param model
 157  
      *            - Top level object containing the data (could be the form or a
 158  
      *            top level business object, dto)
 159  
      */
 160  
     public void performApplyModel(View view, Object model);
 161  
 
 162  
     /**
 163  
      * The last phase before the view is rendered. Here final preparations can
 164  
      * be made based on the updated view state
 165  
      * 
 166  
      * 
 167  
      * @param view
 168  
      *            - view instance that should be finalized for rendering
 169  
      * @param model
 170  
      *            - top level object containing the data
 171  
      * @param parent
 172  
      *            - parent component
 173  
      */
 174  
     public void performFinalize(View view, Object model, Component parent);
 175  
 
 176  
     /**
 177  
      * List of components that are contained within the component
 178  
      * 
 179  
      * <p>
 180  
      * Used by <code>ViewHelperService</code> for the various lifecycle
 181  
      * callbacks
 182  
      * </p>
 183  
      * 
 184  
      * @return List<Component> child components
 185  
      */
 186  
     public List<Component> getNestedComponents();
 187  
 
 188  
     /**
 189  
      * <code>ComponentModifier</code> instances that should be invoked to
 190  
      * initialize the component
 191  
      * 
 192  
      * <p>
 193  
      * These provide dynamic initialization behavior for the component and are
 194  
      * configured through the components definition. Each initializer will get
 195  
      * invoked by the initialize method.
 196  
      * </p>
 197  
      * 
 198  
      * @return List of component modifiers
 199  
      * @see ViewHelperService#initializeComponent
 200  
      */
 201  
     public List<ComponentModifier> getComponentModifiers();
 202  
 
 203  
     /**
 204  
      * Setter for the components List of <code>ComponentModifier</code>
 205  
      * instances
 206  
      * 
 207  
      * @param componentModifiers
 208  
      */
 209  
     public void setComponentModifiers(List<ComponentModifier> componentModifiers);
 210  
 
 211  
     /**
 212  
      * Used by the copy process to determine for which properties only the value
 213  
      * reference should be copied (not a new copy instance). Subclasses can
 214  
      * define the properties for which only the reference should be copied
 215  
      * 
 216  
      * @return Set<String> property names for which only the value reference
 217  
      *         should be copied
 218  
      * @see org.kuali.rice.kns.uif.util.ComponentUtils.copy(T)
 219  
      */
 220  
     public Set<String> getPropertiesForReferenceCopy();
 221  
 
 222  
     /**
 223  
      * Indicates whether the component should be rendered in the UI
 224  
      * 
 225  
      * <p>
 226  
      * If set to false, the corresponding component template will not be invoked
 227  
      * (therefore nothing will be rendered to the UI).
 228  
      * </p>
 229  
      * 
 230  
      * @return boolean true if the component should be rendered, false if it
 231  
      *         should not be
 232  
      */
 233  
     public boolean isRender();
 234  
 
 235  
     /**
 236  
      * Setter for the components render indicator
 237  
      * 
 238  
      * @param render
 239  
      */
 240  
     public void setRender(boolean render);
 241  
 
 242  
     /**
 243  
      * Indicates whether the component should be hidden in the UI
 244  
      * 
 245  
      * <p>
 246  
      * How the hidden data is maintained depends on the views persistence mode.
 247  
      * If the mode is request, the corresponding data will be rendered to the UI
 248  
      * but not visible. If the mode is session, the data will not be rendered to
 249  
      * the UI but maintained server side.
 250  
      * </p>
 251  
      * 
 252  
      * <p>
 253  
      * For a <code>Container</code> component, the hidden setting will apply to
 254  
      * all contained components (making a section hidden makes all fields within
 255  
      * the section hidden)
 256  
      * </p>
 257  
      * 
 258  
      * @return boolean true if the component should be hidden, false if it
 259  
      *         should be visible
 260  
      */
 261  
     public boolean isHidden();
 262  
 
 263  
     /**
 264  
      * Setter for the hidden indicator
 265  
      * 
 266  
      * @param hidden
 267  
      */
 268  
     public void setHidden(boolean hidden);
 269  
 
 270  
     /**
 271  
      * Indicates whether the component can be edited
 272  
      * 
 273  
      * <p>
 274  
      * When readOnly the controls and widgets of <code>Field</code> components
 275  
      * will not be rendered. If the Field has an underlying value it will be
 276  
      * displayed readOnly to the user.
 277  
      * </p>
 278  
      * 
 279  
      * <p>
 280  
      * For a <code>Container</code> component, the readOnly setting will apply
 281  
      * to all contained components (making a section readOnly makes all fields
 282  
      * within the section readOnly)
 283  
      * </p>
 284  
      * </p>
 285  
      * 
 286  
      * @return boolean true if the component should be readOnly, false if is
 287  
      *         allows editing
 288  
      */
 289  
     public boolean isReadOnly();
 290  
 
 291  
     /**
 292  
      * Setter for the read only indicator
 293  
      * 
 294  
      * @param readOnly
 295  
      */
 296  
     public void setReadOnly(boolean readOnly);
 297  
 
 298  
     /**
 299  
      * Expression language string for conditionally setting the readOnly
 300  
      * property
 301  
      * 
 302  
      * @return String el that should evaluate to boolean
 303  
      */
 304  
     public String getConditionalReadOnly();
 305  
 
 306  
     /**
 307  
      * Setter for the conditional readOnly string
 308  
      * 
 309  
      * @param conditionalReadOnly
 310  
      */
 311  
     public void setConditionalReadOnly(String conditionalReadOnly);
 312  
 
 313  
     /**
 314  
      * Indicates whether the component is required
 315  
      * 
 316  
      * <p>
 317  
      * At the general component level required means there is some action the
 318  
      * user needs to take within the component. For example, within a section it
 319  
      * might mean the fields within the section should be completed. At a field
 320  
      * level, it means the field should be completed. This provides the ability
 321  
      * for the renderers to indicate the required action.
 322  
      * </p>
 323  
      * 
 324  
      * @return boolean true if the component is required, false if it is not
 325  
      *         required
 326  
      */
 327  
     public Boolean getRequired();
 328  
 
 329  
     /**
 330  
      * Setter for the required indicator
 331  
      * 
 332  
      * @param required
 333  
      */
 334  
     public void setRequired(Boolean required);
 335  
 
 336  
     /**
 337  
      * CSS style string to be applied to the component
 338  
      * 
 339  
      * <p>
 340  
      * Any style override or additions can be specified with this attribute.
 341  
      * This is used by the renderer to set the style attribute on the
 342  
      * corresponding element.
 343  
      * </p>
 344  
      * 
 345  
      * <p>
 346  
      * e.g. 'color: #000000;text-decoration: underline;'
 347  
      * </p>
 348  
      * 
 349  
      * @return String css style string
 350  
      */
 351  
     public String getStyle();
 352  
 
 353  
     /**
 354  
      * Setter for the components style
 355  
      * 
 356  
      * @param style
 357  
      */
 358  
     public void setStyle(String style);
 359  
 
 360  
     /**
 361  
      * CSS style class(s) to be applied to the component
 362  
      * 
 363  
      * <p>
 364  
      * Declares style classes for the component. Multiple classes are specified
 365  
      * with a space delimiter. This is used by the renderer to set the class
 366  
      * attribute on the corresponding element. The class(s) declared must be
 367  
      * available in the common style sheets or the style sheets specified for
 368  
      * the view
 369  
      * </p>
 370  
      * 
 371  
      * <p>
 372  
      * e.g. 'header left'
 373  
      * </p>
 374  
      * 
 375  
      * @return List<String> css style classes to apply
 376  
      */
 377  
     public List<String> getStyleClasses();
 378  
 
 379  
     /**
 380  
      * Setter for the components style classes
 381  
      * 
 382  
      * @param styleClass
 383  
      */
 384  
     public void setStyleClasses(List<String> styleClasses);
 385  
 
 386  
     /**
 387  
      * Adds a single style to the list of styles on this component
 388  
      * 
 389  
      * @param style
 390  
      */
 391  
     public void addStyleClass(String styleClass);
 392  
 
 393  
     /**
 394  
      * TODO: javadoc
 395  
      * 
 396  
      * @param itemStyle
 397  
      */
 398  
     public void appendToStyle(String itemStyle);
 399  
 
 400  
     /**
 401  
      * Number of places the component should take up horizontally in the
 402  
      * container
 403  
      * 
 404  
      * <p>
 405  
      * All components belong to a <code>Container</code> and are placed using a
 406  
      * <code>LayoutManager</code>. This property specifies how many places
 407  
      * horizontally the component should take up within the container. This is
 408  
      * only applicable for table based layout managers. Default is 1
 409  
      * </p>
 410  
      * 
 411  
      * TODO: this should not be on component interface since it only applies if
 412  
      * the layout manager supports it, need some sort of layoutOptions map for
 413  
      * field level options that depend on the manager
 414  
      * 
 415  
      * @return int number of columns to span
 416  
      */
 417  
     public int getColSpan();
 418  
 
 419  
     /**
 420  
      * Setter for the components column span
 421  
      * 
 422  
      * @param colSpan
 423  
      */
 424  
     public void setColSpan(int colSpan);
 425  
 
 426  
     /**
 427  
      * Number of places the component should take up vertically in the container
 428  
      * 
 429  
      * <p>
 430  
      * All components belong to a <code>Container</code> and are placed using a
 431  
      * <code>LayoutManager</code>. This property specifies how many places
 432  
      * vertically the component should take up within the container. This is
 433  
      * only applicable for table based layout managers. Default is 1
 434  
      * </p>
 435  
      * 
 436  
      * TODO: this should not be on component interface since it only applies if
 437  
      * the layout manager supports it, need some sort of layoutOptions map for
 438  
      * field level options that depend on the manager
 439  
      * 
 440  
      * @return int number of rows to span
 441  
      */
 442  
     public int getRowSpan();
 443  
 
 444  
     /**
 445  
      * Setter for the component row span
 446  
      * 
 447  
      * @param rowSpan
 448  
      */
 449  
     public void setRowSpan(int rowSpan);
 450  
 
 451  
     /**
 452  
      * Context map for the component
 453  
      * 
 454  
      * <p>
 455  
      * Any el statements configured for the components properties (e.g.
 456  
      * title="@{foo.property}") are evaluated using the el context map. This map
 457  
      * will get populated with default objects like the model, view, and request
 458  
      * from the <code>ViewHelperService</code>. Other components can push
 459  
      * further objects into the context so that they are available for use with
 460  
      * that component. For example, <code>Field</code> instances that are part
 461  
      * of a collection line as receive the current line instance
 462  
      * </p>
 463  
      * 
 464  
      * <p>
 465  
      * Context map also provides objects to methods that are invoked for
 466  
      * <code>GeneratedField</code> instances
 467  
      * </p>
 468  
      * 
 469  
      * <p>
 470  
      * The Map key gives the name of the variable that can be used within
 471  
      * expressions, and the Map value gives the object instance for which
 472  
      * expressions containing the variable should evaluate against
 473  
      * </p>
 474  
      * 
 475  
      * @return Map<String, Object> context
 476  
      */
 477  
     public Map<String, Object> getContext();
 478  
 
 479  
     /**
 480  
      * Setter for the context Map
 481  
      * 
 482  
      * @param context
 483  
      */
 484  
     public void setContext(Map<String, Object> context);
 485  
 
 486  
     /**
 487  
      * Places the given object into the context Map for the component with the
 488  
      * given name
 489  
      * 
 490  
      * @param objectName
 491  
      *            - name the object should be exposed under in the context map
 492  
      * @param object
 493  
      *            - object instance to place into context
 494  
      */
 495  
     public void pushObjectToContext(String objectName, Object object);
 496  
 
 497  
     /**
 498  
      * List of <code>PropertyReplacer</code> instances that will be evaluated
 499  
      * during the view lifecycle to conditional set properties on the
 500  
      * <code>Component</code> based on expression evaluations
 501  
      * 
 502  
      * @return List<PropertyReplacer> replacers to evaluate
 503  
      */
 504  
     public List<PropertyReplacer> getPropertyReplacers();
 505  
 
 506  
     /**
 507  
      * Setter for the components property substitutions
 508  
      * 
 509  
      * @param propertyReplacers
 510  
      */
 511  
     public void setPropertyReplacers(List<PropertyReplacer> propertyReplacers);
 512  
 
 513  
     /**
 514  
      * Options that are passed through to the Component renderer. The Map key is
 515  
      * the option name, with the Map value as the option value. See
 516  
      * documentation on the particular widget render for available options.
 517  
      * 
 518  
      * @return Map<String, String> options
 519  
      */
 520  
     public Map<String, String> getComponentOptions();
 521  
 
 522  
     /**
 523  
      * Setter for the widget's options
 524  
      * 
 525  
      * @param widgetOptions
 526  
      */
 527  
     public void setComponentOptions(Map<String, String> componentOptions);
 528  
 
 529  
     /**
 530  
      * Can be used to order a component within a List of other components, lower
 531  
      * numbers are placed higher up in the list, while higher numbers are placed
 532  
      * lower in the list
 533  
      * 
 534  
      * @return int ordering number
 535  
      * @see org.springframework.core.Ordered#getOrder()
 536  
      */
 537  
     public int getOrder();
 538  
 
 539  
     /**
 540  
      * Setter for the component's order
 541  
      * 
 542  
      * @param order
 543  
      */
 544  
     public void setOrder(int order);
 545  
 
 546  
 }