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.ext;
20  
21  import java.io.IOException;
22  
23  import javax.faces.component.UIComponent;
24  import javax.faces.component.UIInput;
25  import javax.faces.component.UIOutput;
26  import javax.faces.context.FacesContext;
27  import javax.faces.context.ResponseWriter;
28  import javax.faces.convert.ConverterException;
29  
30  import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
31  import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
32  import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
33  import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRenderer;
34  import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
35  
36  
37  /**
38   * @JSFRenderer
39   *   renderKitId="HTML_BASIC"
40   *   family="javax.faces.Input"
41   *   type="org.apache.myfaces.Hidden"
42   * 
43   * @since 1.1.7
44   * @author Thomas Spiegl (latest modification by $Author: lu4242 $)
45   * @author Anton Koinov
46   * @version $Revision: 691871 $ $Date: 2008-09-03 23:32:08 -0500 (Wed, 03 Sep 2008) $
47   */
48  public class HtmlHiddenRenderer
49  extends HtmlRenderer
50  {
51      public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
52          throws IOException
53      {
54          RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class);
55  
56          ResponseWriter writer = facesContext.getResponseWriter();
57  
58          writer.startElement(HTML.INPUT_ELEM, uiComponent);
59          writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
60  
61          String clientId = uiComponent.getClientId(facesContext);
62          writer.writeAttribute(HTML.ID_ATTR, clientId, null);
63          writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
64  
65          String value = RendererUtils.getStringValue(facesContext, uiComponent);
66          if (value != null)
67          {
68              writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR);
69          }
70  
71          writer.endElement(HTML.INPUT_ELEM);
72      }
73  
74      public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException
75      {
76          RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
77          return RendererUtils.getConvertedUIOutputValue(facesContext,
78                                                         (UIOutput)uiComponent,
79                                                         submittedValue);
80      }
81  
82  
83      public void decode(FacesContext facesContext, UIComponent component)
84       {
85           RendererUtils.checkParamValidity(facesContext,component,UIInput.class);
86  
87           HtmlRendererUtils.decodeUIInput(facesContext, component);
88  
89       }
90  
91  }