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 * $Id:SelectBooleanCheckboxRenderer.java 472227 2006-11-07 21:05:00 +0100 (Tue, 07 Nov 2006) bommel $
023 */
024
025 import static org.apache.myfaces.tobago.TobagoConstants.ATTR_VALUE;
026 import static org.apache.myfaces.tobago.TobagoConstants.FACET_LABEL;
027 import org.apache.myfaces.tobago.util.ComponentUtil;
028 import org.apache.myfaces.tobago.renderkit.LayoutableRendererBase;
029 import org.apache.myfaces.tobago.renderkit.util.RenderUtil;
030 import org.apache.myfaces.tobago.renderkit.html.HtmlConstants;
031 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtil;
032 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
033
034 import javax.faces.component.UIComponent;
035 import javax.faces.context.FacesContext;
036 import java.io.IOException;
037
038 public class SelectBooleanCheckboxRenderer extends LayoutableRendererBase {
039
040 public void encodeEnd(FacesContext facesContext, UIComponent component)
041 throws IOException {
042
043 TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
044
045 boolean value = ComponentUtil.getBooleanAttribute(component, ATTR_VALUE);
046
047 writer.startElement(HtmlConstants.SELECT, component);
048 writer.writeNameAttribute(component.getClientId(facesContext));
049 writer.writeIdAttribute(component.getClientId(facesContext));
050 writer.writeAttribute("multiple", true);
051 writer.startElement(HtmlConstants.OPTION, null);
052 writer.writeAttribute("value", value ? "on" : "off", false);
053
054 UIComponent label = component.getFacet(FACET_LABEL);
055 if (label != null) {
056 RenderUtil.encode(facesContext, label);
057 }
058
059 writer.endElement(HtmlConstants.OPTION);
060 writer.endElement(HtmlConstants.SELECT);
061 }
062 }