1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.wcm.webui.container;
18
19 import java.io.Writer;
20
21 import org.exoplatform.webui.application.WebuiRequestContext;
22 import org.exoplatform.webui.core.UIComponent;
23 import org.exoplatform.webui.core.UIContainer;
24 import org.exoplatform.webui.form.UIForm;
25
26
27
28
29
30
31
32 public class UIFormFieldSet extends UIContainer {
33
34
35
36
37
38
39 public UIFormFieldSet(String name) {
40 setId(name) ;
41 }
42
43
44
45
46 public void processDecode(WebuiRequestContext context) throws Exception {
47 for(UIComponent child : getChildren()) {
48 child.processDecode(context) ;
49 }
50 }
51
52
53
54
55 public void processRender(WebuiRequestContext context) throws Exception {
56 if (getComponentConfig() != null) {
57 super.processRender(context);
58 return;
59 }
60 UIForm uiForm = getAncestorOfType(UIForm.class);
61 Writer writer = context.getWriter() ;
62 writer.write("<div class=\"" + getId() + "\">") ;
63 writer.write("<fieldset>") ;
64 writer.write("<legend>" + uiForm.getLabel(getId()) + "</legend>") ;
65 writer.write("<table class=\"UIFormGrid\">") ;
66 for(UIComponent component : getChildren()) {
67 if(component.isRendered()) {
68 writer.write("<tr>") ;
69 String componentName = uiForm.getLabel(component.getId());
70 if(componentName != null && componentName.length() > 0 && !componentName.equals(getId())) {
71 writer.write("<td class=\"FieldLabel\"><label for=\"" + component.getId() + "\">" + componentName + "</td>");
72 writer.write("<td class=\"FieldComponent\">") ;
73 renderUIComponent(component) ;
74 writer.write("</td>") ;
75 } else {
76 writer.write("<td class=\"FieldComponent\" colspans=\"2\">") ;
77 renderUIComponent(component) ;
78 writer.write("</td>") ;
79 }
80 writer.write("</tr>") ;
81 }
82 }
83 writer.write("</table>") ;
84 writer.write("</fieldset>") ;
85 writer.write("</div>") ;
86 }
87 }