1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.custom.dynaForm.metadata.impl.jsf;
20
21
22 import java.util.Iterator;
23
24 import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaConfig;
25 import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaConfigs;
26 import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaForm;
27 import org.apache.myfaces.custom.dynaForm.metadata.Extractor;
28 import org.apache.myfaces.custom.dynaForm.metadata.MetaData;
29
30 /***
31 * Extract metadata from jsf form.<br />
32 * This will read all facets with "ff_" name prefix but nothing will be configured.
33 * Its just there to collect which fields to show if in exclusiveFieldMode
34 */
35 public class JsfRequestFieldExtractor implements Extractor
36 {
37 public JsfRequestFieldExtractor()
38 {
39 }
40
41 public void getMetaData(MetaData metaData, Object entity)
42 {
43 if (!(entity instanceof DynaForm))
44 {
45 throw new IllegalArgumentException("passed entity argument not a DynaForm: " + entity);
46 }
47
48 create(metaData, (DynaForm) entity);
49 }
50
51 /***
52 * create the metadata out of the dynaConfigs for the given component
53 */
54 @SuppressWarnings("unchecked")
55 protected void create(MetaData metaData, DynaForm dynaForm)
56 {
57 DynaConfigs formConfig = dynaForm.getFormConfigs();
58 if (formConfig == null)
59 {
60 return;
61 }
62
63 Iterator<DynaConfig> entries = formConfig.iterator();
64 while (entries.hasNext())
65 {
66 DynaConfig dynaConfig = entries.next();
67 String name = dynaConfig.getFor();
68 if (name == null)
69 {
70 throw new IllegalArgumentException("'for' in config tag required");
71 }
72
73 if (metaData.processField(name))
74 {
75 metaData.requestField(name);
76 }
77 }
78 }
79 }