KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > formview > displayer > test > TestDisplayersConfig


1 package net.sourceforge.formview.displayer.test;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5
6 import org.xml.sax.SAXException JavaDoc;
7
8 import net.sourceforge.formview.FieldView;
9 import net.sourceforge.formview.FormViewException;
10 import net.sourceforge.formview.displayer.DisplayerConfig;
11 import net.sourceforge.formview.displayer.DisplayersConfigResources;
12
13 public class TestDisplayersConfig {
14
15     /**
16      * @param args
17      */

18     public static void main(String JavaDoc[] args) throws FormViewException, IOException JavaDoc, SAXException JavaDoc {
19         InputStream JavaDoc inDisplayerConfig = null;
20         // Load DisplayersConfigResources
21
DisplayersConfigResources resources = null;
22         try {
23             
24             inDisplayerConfig = DisplayersConfigResources.class.getResourceAsStream("displayers-config.xml");
25             resources = new DisplayersConfigResources(inDisplayerConfig);
26             
27         } finally {
28 // Make sure we close the input stream.
29
if (inDisplayerConfig != null) {
30                 inDisplayerConfig.close();
31             }
32
33         }
34         
35         // Display config of input type="text"
36
DisplayerConfig displayerConfig = resources.getDisplayerConfig("input_text");
37         System.out.println(displayerConfig.toString());
38         
39         // Display config of select
40
displayerConfig = resources.getDisplayerConfig("select");
41         System.out.println(displayerConfig.toString());
42         
43         // Display HTML with READ-WRITE
44
FieldView field = new FieldView();
45         field.setProperty("nom");
46         
47         
48         String JavaDoc htmlInputContent = getHtmlInputContent();
49         //displayerConfig.processHTML("input_text", htmlInputContent);
50
System.out.println(htmlInputContent);
51
52     }
53     
54     private static String JavaDoc getHtmlInputContent() {
55         StringBuffer JavaDoc htmlContent = new StringBuffer JavaDoc("");
56         htmlContent.append("<input name=\"nom\" type=\"text\" >\n");
57         return htmlContent.toString();
58     }
59
60 }
61
Popular Tags