1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package javax.faces.component.html; |
17 | |
|
18 | |
import javax.faces.component.UIInput; |
19 | |
import javax.faces.context.FacesContext; |
20 | |
import javax.faces.el.ValueBinding; |
21 | |
import javax.faces.internal.FacesMessageUtil; |
22 | |
|
23 | |
import org.seasar.framework.util.AssertionUtil; |
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
public class HtmlInputHidden extends UIInput { |
30 | |
|
31 | |
public static final String COMPONENT_TYPE = "javax.faces.HtmlInputHidden"; |
32 | |
|
33 | |
private static final String DEFAULT_RENDERER_TYPE = "javax.faces.Hidden"; |
34 | |
|
35 | 131 | public HtmlInputHidden() { |
36 | 131 | setRendererType(DEFAULT_RENDERER_TYPE); |
37 | 131 | } |
38 | |
|
39 | |
public void processValidators(FacesContext context) { |
40 | 2 | AssertionUtil.assertNotNull("context", context); |
41 | 1 | if (!isRendered()) { |
42 | 0 | return; |
43 | |
} |
44 | 1 | super.processValidators(context); |
45 | 1 | if (!isImmediate()) { |
46 | 1 | executeValidate(context); |
47 | |
} |
48 | |
try { |
49 | 1 | updateModelImmediately(context); |
50 | 0 | } catch (RuntimeException e) { |
51 | 0 | context.renderResponse(); |
52 | 0 | throw e; |
53 | 1 | } |
54 | 1 | } |
55 | |
|
56 | |
protected void updateModelImmediately(FacesContext context) { |
57 | 1 | AssertionUtil.assertNotNull("context", context); |
58 | 1 | if (!isValid() || !isLocalValueSet()) { |
59 | 0 | return; |
60 | |
} |
61 | 1 | final ValueBinding valueBinding = getValueBinding("value"); |
62 | 1 | if (valueBinding == null) { |
63 | 0 | return; |
64 | |
} |
65 | |
try { |
66 | 1 | Object localValue = getLocalValue(); |
67 | 1 | valueBinding.setValue(context, localValue); |
68 | 0 | } catch (RuntimeException e) { |
69 | 0 | Object[] args = { getId() }; |
70 | 0 | context.getExternalContext().log(e.getMessage(), e); |
71 | 0 | FacesMessageUtil.addErrorComponentMessage(context, this, |
72 | |
CONVERSION_MESSAGE_ID, args); |
73 | 0 | setValid(false); |
74 | 1 | } |
75 | 1 | } |
76 | |
} |