View Javadoc
1   /*
2    * Copyright 2008 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.ole.sys.document.web.renderers;
17  
18  import javax.servlet.jsp.JspException;
19  import javax.servlet.jsp.PageContext;
20  import javax.servlet.jsp.tagext.Tag;
21  
22  import org.kuali.rice.kns.web.taglib.html.KNSCheckboxTag;
23  
24  /**
25   * Renders a field as a checkbox control
26   */
27  public class CheckboxRenderer extends FieldRendererBase {
28      private KNSCheckboxTag checkboxTag = new KNSCheckboxTag();
29  
30      /**
31       * 
32       * @see org.kuali.ole.sys.document.web.renderers.FieldRendererBase#clear()
33       */
34      @Override
35      public void clear() {
36          super.clear();
37          checkboxTag.setProperty(null);
38          checkboxTag.setTitle(null);
39          checkboxTag.setOnblur(null);
40          checkboxTag.setStyleId(null);
41          checkboxTag.setPageContext(null);
42          checkboxTag.setParent(null);
43          checkboxTag.setValue(null);
44          checkboxTag.setTabindex(null);
45      }
46  
47      /**
48       * 
49       * @see org.kuali.ole.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
50       */
51      public void render(PageContext pageContext, Tag parentTag) throws JspException {
52          renderCheckboxTag(pageContext, parentTag);
53          if (isShowError()) {
54              renderErrorIcon(pageContext);
55          }
56      }
57  
58      /**
59       * Renders the checkbox portion of this checkbox tag
60       * @param pageContext the page context to render to
61       * @param parentTag the parent tag requesting all this rendering
62       * @param propertyPrefix the property from the form to the business object
63       */
64      protected void renderCheckboxTag(PageContext pageContext, Tag parentTag) throws JspException {
65          checkboxTag.setPageContext(pageContext);
66          checkboxTag.setParent(parentTag);
67          checkboxTag.setProperty(getFieldName());
68          checkboxTag.setTitle(this.getAccessibleTitle());
69          checkboxTag.setOnblur(this.buildOnBlur());
70          checkboxTag.setStyleId(getFieldName());
71          
72          checkboxTag.setPageContext(pageContext);
73          checkboxTag.setParent(parentTag);
74          
75          checkboxTag.doStartTag();
76          checkboxTag.doEndTag();
77      }
78  
79      /**
80       * I'm not really into quick finders
81       * @see org.kuali.ole.sys.document.web.renderers.FieldRenderer#renderQuickfinder()
82       */
83      public boolean renderQuickfinder() {
84          return false;
85      }
86      
87  }