View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.renderkit.html;
20  
21  import org.apache.myfaces.shared_impl.renderkit.JSFAttr;
22  import org.apache.myfaces.shared_impl.renderkit.RendererUtils;
23  import org.apache.myfaces.shared_impl.renderkit.html.HTML;
24  import org.apache.myfaces.shared_impl.renderkit.html.HtmlRenderer;
25  import org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils;
26  
27  import javax.faces.component.UIComponent;
28  import javax.faces.component.UIInput;
29  import javax.faces.component.UIOutput;
30  import javax.faces.context.FacesContext;
31  import javax.faces.context.ResponseWriter;
32  import javax.faces.convert.ConverterException;
33  import java.io.IOException;
34  
35  
36  /**
37   * @JSFRenderer
38   *   renderKitId="HTML_BASIC"
39   *   family="javax.faces.Input"
40   *   type="javax.faces.Hidden"
41   *   
42   * @author Thomas Spiegl (latest modification by $Author: lu4242 $)
43   * @author Anton Koinov
44   * @version $Revision: 659857 $ $Date: 2008-05-24 13:17:47 -0500 (Sat, 24 May 2008) $
45   */
46  public class HtmlHiddenRenderer
47  extends HtmlRenderer
48  {
49      public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
50          throws IOException
51      {
52          RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class);
53  
54          ResponseWriter writer = facesContext.getResponseWriter();
55  
56          writer.startElement(HTML.INPUT_ELEM, uiComponent);
57          writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
58  
59          String clientId = uiComponent.getClientId(facesContext);
60          writer.writeAttribute(HTML.ID_ATTR, clientId, null);
61          writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
62  
63          String value = RendererUtils.getStringValue(facesContext, uiComponent);
64          if (value != null)
65          {
66              writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR);
67          }
68  
69          writer.endElement(HTML.INPUT_ELEM);
70      }
71  
72      public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException
73      {
74          RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
75          return RendererUtils.getConvertedUIOutputValue(facesContext,
76                                                         (UIOutput)uiComponent,
77                                                         submittedValue);
78      }
79  
80  
81      public void decode(FacesContext facesContext, UIComponent component)
82       {
83           RendererUtils.checkParamValidity(facesContext,component,UIInput.class);
84  
85           HtmlRendererUtils.decodeUIInput(facesContext, component);
86  
87       }
88  
89  }