001 /*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.kfs.sys.document.web.renderers;
017
018 import javax.servlet.jsp.JspException;
019 import javax.servlet.jsp.PageContext;
020 import javax.servlet.jsp.tagext.Tag;
021
022 import org.kuali.rice.kns.web.taglib.html.KNSCheckboxTag;
023
024 /**
025 * Renders a field as a checkbox control
026 */
027 public class CheckboxRenderer extends FieldRendererBase {
028 private KNSCheckboxTag checkboxTag = new KNSCheckboxTag();
029
030 /**
031 *
032 * @see org.kuali.kfs.sys.document.web.renderers.FieldRendererBase#clear()
033 */
034 @Override
035 public void clear() {
036 super.clear();
037 checkboxTag.setProperty(null);
038 checkboxTag.setTitle(null);
039 checkboxTag.setOnblur(null);
040 checkboxTag.setStyleId(null);
041 checkboxTag.setPageContext(null);
042 checkboxTag.setParent(null);
043 checkboxTag.setValue(null);
044 checkboxTag.setTabindex(null);
045 }
046
047 /**
048 *
049 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
050 */
051 public void render(PageContext pageContext, Tag parentTag) throws JspException {
052 renderCheckboxTag(pageContext, parentTag);
053 if (isShowError()) {
054 renderErrorIcon(pageContext);
055 }
056 }
057
058 /**
059 * Renders the checkbox portion of this checkbox tag
060 * @param pageContext the page context to render to
061 * @param parentTag the parent tag requesting all this rendering
062 * @param propertyPrefix the property from the form to the business object
063 */
064 protected void renderCheckboxTag(PageContext pageContext, Tag parentTag) throws JspException {
065 checkboxTag.setPageContext(pageContext);
066 checkboxTag.setParent(parentTag);
067 checkboxTag.setProperty(getFieldName());
068 checkboxTag.setTitle(this.getAccessibleTitle());
069 checkboxTag.setOnblur(this.buildOnBlur());
070 checkboxTag.setStyleId(getFieldName());
071
072 checkboxTag.setPageContext(pageContext);
073 checkboxTag.setParent(parentTag);
074
075 checkboxTag.doStartTag();
076 checkboxTag.doEndTag();
077 }
078
079 /**
080 * I'm not really into quick finders
081 * @see org.kuali.kfs.sys.document.web.renderers.FieldRenderer#renderQuickfinder()
082 */
083 public boolean renderQuickfinder() {
084 return false;
085 }
086
087 }