1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.renderkit.html; |
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.buildtools.maven2.plugin.builder.annotation.JSFRenderer; |
31 | |
import org.apache.myfaces.shared_impl.renderkit.JSFAttr; |
32 | |
import org.apache.myfaces.shared_impl.renderkit.RendererUtils; |
33 | |
import org.apache.myfaces.shared_impl.renderkit.html.HTML; |
34 | |
import org.apache.myfaces.shared_impl.renderkit.html.HtmlRenderer; |
35 | |
import org.apache.myfaces.shared_impl.renderkit.html.HtmlRendererUtils; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
@JSFRenderer( |
45 | |
renderKitId="HTML_BASIC", |
46 | |
family="javax.faces.Input", |
47 | |
type="javax.faces.Hidden") |
48 | 0 | public class HtmlHiddenRenderer |
49 | |
extends HtmlRenderer |
50 | |
{ |
51 | |
public void encodeEnd(FacesContext facesContext, UIComponent uiComponent) |
52 | |
throws IOException |
53 | |
{ |
54 | 0 | RendererUtils.checkParamValidity(facesContext, uiComponent, UIInput.class); |
55 | |
|
56 | 0 | ResponseWriter writer = facesContext.getResponseWriter(); |
57 | |
|
58 | 0 | writer.startElement(HTML.INPUT_ELEM, uiComponent); |
59 | 0 | writer.writeAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN, null); |
60 | |
|
61 | 0 | String clientId = uiComponent.getClientId(facesContext); |
62 | 0 | writer.writeAttribute(HTML.ID_ATTR, clientId, null); |
63 | 0 | writer.writeAttribute(HTML.NAME_ATTR, clientId, null); |
64 | |
|
65 | 0 | String value = RendererUtils.getStringValue(facesContext, uiComponent); |
66 | 0 | if (value != null) |
67 | |
{ |
68 | 0 | writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR); |
69 | |
} |
70 | |
|
71 | 0 | writer.endElement(HTML.INPUT_ELEM); |
72 | 0 | } |
73 | |
|
74 | |
public Object getConvertedValue(FacesContext facesContext, UIComponent uiComponent, Object submittedValue) throws ConverterException |
75 | |
{ |
76 | 0 | RendererUtils.checkParamValidity(facesContext, uiComponent, UIOutput.class); |
77 | 0 | return RendererUtils.getConvertedUIOutputValue(facesContext, |
78 | |
(UIOutput)uiComponent, |
79 | |
submittedValue); |
80 | |
} |
81 | |
|
82 | |
|
83 | |
public void decode(FacesContext facesContext, UIComponent component) |
84 | |
{ |
85 | 0 | RendererUtils.checkParamValidity(facesContext,component,null); |
86 | |
|
87 | 0 | if (component instanceof UIInput) |
88 | |
{ |
89 | 0 | HtmlRendererUtils.decodeUIInput(facesContext, component); |
90 | |
} |
91 | |
else |
92 | |
{ |
93 | 0 | throw new IllegalArgumentException("Unsupported component class " + component.getClass().getName()); |
94 | |
} |
95 | 0 | } |
96 | |
|
97 | |
} |