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.apache.struts.taglib.html.HiddenTag;
023    import org.springframework.web.util.HtmlUtils;
024    
025    /**
026     * Renders a hidden field
027     */
028    public class HiddenRenderer extends FieldRendererBase {
029        private HiddenTag tag = new HiddenTag();
030    
031        /**
032         * Resets the field on the following values on the tag: the page context, the parent tag, the property, and the value
033         * @see org.kuali.kfs.sys.document.web.renderers.Renderer#clear()
034         */
035        @Override
036        public void clear() {
037            super.clear();
038            tag.setPageContext(null);
039            tag.setParent(null);
040            tag.setProperty(null);
041            tag.setValue(null);
042        }
043    
044        /**
045         * Renders the hidden field using a Struts html:hidden tag
046         * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
047         */
048        public void render(PageContext pageContext, Tag parentTag) throws JspException {
049            tag.setPageContext(pageContext);
050            tag.setParent(parentTag);
051            tag.setProperty(getFieldName());
052            if (getField().isSecure()) {
053                tag.setValue(getField().getEncryptedValue());
054            } else {
055                tag.setValue(HtmlUtils.htmlEscape(getField().getPropertyValue()));
056            }
057            tag.setStyleId(getFieldName());
058            tag.setWrite(false);
059            tag.doStartTag();
060            tag.doEndTag();
061        }
062    
063        /**
064         * You can't even see me...you think I got a quickfinder?
065         * @see org.kuali.kfs.sys.document.web.renderers.FieldRenderer#renderQuickfinder()
066         */
067        public boolean renderQuickfinder() {
068            return false;
069        }
070    
071    }