1
2
3
4
5 package org.rcfaces.core.internal.component;
6
7 import java.util.Iterator;
8
9 import javax.faces.component.UIComponent;
10 import javax.faces.context.FacesContext;
11 import javax.faces.render.Renderer;
12
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15 import org.rcfaces.core.internal.renderkit.IRendererExtension;
16
17
18
19
20
21 public class CameliaComponents {
22 private static final String REVISION = "$Revision: 1.18 $";
23
24 private static final Log LOG = LogFactory.getLog(CameliaComponents.class);
25
26 public static final String FAMILY = "rcfaces";
27
28 public static void processDecodes(FacesContext context,
29 UIComponent component, Renderer renderer) {
30
31 if (LOG.isTraceEnabled()) {
32 LOG.trace("Process decodes of '" + component.getId() + "'.");
33 }
34
35 IRendererExtension rendererExtension = (IRendererExtension) renderer;
36
37 try {
38 renderer.decode(context, component);
39
40 } catch (RuntimeException e) {
41 if (LOG.isDebugEnabled()) {
42 LOG.debug("Process decodes of '" + component.getId()
43 + "' throws exception.", e);
44 }
45
46 context.renderResponse();
47 throw e;
48 }
49
50 if (rendererExtension.getDecodesChildren()) {
51 try {
52 rendererExtension.decodeChildren(context, component);
53
54 } catch (RuntimeException e) {
55 if (LOG.isDebugEnabled()) {
56 LOG.debug("Process decodes of children of component '"
57 + component.getId() + "' throws exception.", e);
58 }
59
60 context.renderResponse();
61 throw e;
62 }
63
64 } else {
65 try {
66 Iterator kids = component.getFacetsAndChildren();
67 while (kids.hasNext()) {
68 UIComponent kid = (UIComponent) kids.next();
69 kid.processDecodes(context);
70 }
71
72 } catch (RuntimeException e) {
73 if (LOG.isDebugEnabled()) {
74 LOG
75 .debug(
76 "Process decodes (by iterator) of children of component '"
77 + component.getId()
78 + "' throws exception.", e);
79 }
80
81 throw e;
82 }
83 }
84
85 try {
86 rendererExtension.decodeEnd(context, component);
87
88 } catch (RuntimeException e) {
89 if (LOG.isDebugEnabled()) {
90 LOG.debug("Process end decodes of children of component '"
91 + component.getId() + "' throws exception.", e);
92 }
93
94 context.renderResponse();
95 throw e;
96 }
97
98 if (LOG.isTraceEnabled()) {
99 LOG.trace("Process decodes of '" + component.getId() + "' DONE.");
100 }
101
102 }
103 }