001    package org.apache.myfaces.tobago.renderkit.wml.standard.standard.tag;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one or more
005     * contributor license agreements.  See the NOTICE file distributed with
006     * this work for additional information regarding copyright ownership.
007     * The ASF licenses this file to You under the Apache License, Version 2.0
008     * (the "License"); you may not use this file except in compliance with
009     * the License.  You may obtain a copy of the License at
010     *
011     *      http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing, software
014     * distributed under the License is distributed on an "AS IS" BASIS,
015     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016     * See the License for the specific language governing permissions and
017     * limitations under the License.
018     */
019    
020    /*
021     * Created 07.02.2003 16:00:00.
022     * : $
023     */
024    
025    import org.apache.commons.collections.keyvalue.DefaultKeyValue;
026    import static org.apache.myfaces.tobago.TobagoConstants.ATTR_PASSWORD;
027    import static org.apache.myfaces.tobago.TobagoConstants.FACET_LABEL;
028    import org.apache.myfaces.tobago.util.ComponentUtil;
029    import org.apache.myfaces.tobago.component.AbstractUIPage;
030    import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
031    import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
032    import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtil;
033    import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
034    
035    import javax.faces.component.UIComponent;
036    import javax.faces.context.FacesContext;
037    import java.io.IOException;
038    
039    public class InRenderer extends LayoutableRendererBase {
040    
041      public void encodeEnd(FacesContext facesContext, UIComponent component)
042          throws IOException {
043    
044        TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
045    
046        String clientId = component.getClientId(facesContext);
047    
048        AbstractUIPage uiPage = ComponentUtil.findPage(facesContext, component);
049    
050        if (uiPage != null) {
051          uiPage.getPostfields().add(new DefaultKeyValue(clientId, clientId));
052        }
053    
054        UIComponent label = component.getFacet(FACET_LABEL);
055        if (label != null) {
056          RenderUtil.encode(facesContext, label);
057        }
058    
059        String currentValue = RenderUtil.currentValue(component);
060    
061        String type = ComponentUtil.getBooleanAttribute(
062            component, ATTR_PASSWORD) ? "password" : "text";
063    
064        writer.startElement("input", component);
065        writer.writeNameAttribute(clientId);
066        writer.writeIdAttribute(clientId);
067        writer.writeAttribute("value", currentValue, true);
068        writer.writeAttribute("type", type, false);
069        writer.endElement("input");
070    
071    
072      }
073    }
074