KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > renderkit > html > HtmlHiddenRenderer


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.myfaces.renderkit.html;
17
18 import org.apache.myfaces.renderkit.JSFAttr;
19 import org.apache.myfaces.renderkit.RendererUtils;
20
21 import javax.faces.component.UIComponent;
22 import javax.faces.component.UIInput;
23 import javax.faces.component.UIOutput;
24 import javax.faces.context.FacesContext;
25 import javax.faces.context.ResponseWriter;
26 import javax.faces.convert.ConverterException;
27 import java.io.IOException JavaDoc;
28
29
30 /**
31  * @author Thomas Spiegl (latest modification by $Author: matze $)
32  * @author Anton Koinov
33  * @version $Revision: 1.11 $ $Date: 2004/10/13 11:51:00 $
34  * $Log: HtmlHiddenRenderer.java,v $
35  * Revision 1.11 2004/10/13 11:51:00 matze
36  * renamed packages to org.apache
37  *
38  * Revision 1.10 2004/07/01 22:05:06 mwessendorf
39  * ASF switch
40  *
41  * Revision 1.9 2004/05/12 07:57:44 manolito
42  * Log in javadoc header
43  *
44  * Revision 1.8 2004/05/05 21:22:50 o_rossmueller
45  * fix #948110: decode for hidden fields
46  *
47  * Revision 1.7 2004/03/26 13:34:04 manolito
48  * fixed value attribute output
49  */

50 public class HtmlHiddenRenderer
51 extends HtmlRenderer
52 {
53     public void encodeEnd(FacesContext facesContext, UIComponent uiComponent)
54         throws IOException JavaDoc
55     {
56         RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class);
57
58         ResponseWriter writer = facesContext.getResponseWriter();
59
60         writer.startElement(HTML.INPUT_ELEM, uiComponent);
61         writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null);
62
63         String JavaDoc clientId = uiComponent.getClientId(facesContext);
64         writer.writeAttribute(HTML.ID_ATTR, clientId, null);
65         writer.writeAttribute(HTML.NAME_ATTR, clientId, null);
66
67         String JavaDoc value = RendererUtils.getStringValue(facesContext, uiComponent);
68         if (value != null)
69         {
70             writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR);
71         }
72         
73         writer.endElement(HTML.INPUT_ELEM);
74     }
75
76     public Object JavaDoc getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object JavaDoc submittedValue) throws ConverterException
77     {
78         RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class);
79         return RendererUtils.getConvertedUIOutputValue(facesContext,
80                                                        (UIOutput)uiComponent,
81                                                        submittedValue);
82     }
83
84     
85     public void decode(FacesContext facesContext, UIComponent component)
86      {
87          RendererUtils.checkParamValidity(facesContext,component,null);
88
89          if (component instanceof UIInput)
90          {
91              HtmlRendererUtils.decodeUIInput(facesContext, component);
92          }
93          else
94          {
95              throw new IllegalArgumentException JavaDoc("Unsupported component class " + component.getClass().getName());
96          }
97      }
98
99 }
100
Popular Tags