KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > formview > test > FormViewTestIfCondition


1 package net.sourceforge.formview.test;
2
3 import java.io.IOException JavaDoc;
4 import java.io.InputStream JavaDoc;
5
6 import net.sourceforge.formview.FormView;
7 import net.sourceforge.formview.FormViewException;
8 import net.sourceforge.formview.FormViewResources;
9 import net.sourceforge.formview.displayer.DisplayersConfigResources;
10 import net.sourceforge.formview.permission.IPermissionsAdapter;
11 import net.sourceforge.formview.util.ApplicationFormViewUtil;
12 import net.sourceforge.formview.validator.ExtendedValidatorResources;
13
14 import org.xml.sax.SAXException JavaDoc;
15
16 public class FormViewTestIfCondition {
17
18     /**
19      * @param args
20      */

21     public static void main(String JavaDoc[] args)
22         throws FormViewException, IOException JavaDoc, SAXException JavaDoc {
23         InputStream JavaDoc inFomView = null;
24
25         
26         // Load Form view
27
FormViewResources resources = null;
28         try {
29             
30             // Create a new instance of a ValidatorResource, then get a stream
31
// handle on the XML file with the actions in it, and initialize the
32
// resources from it. This would normally be done by a servlet
33
// run during JSP initialization or some other application-startup
34
// routine.
35

36             inFomView = FormViewTest.class.getResourceAsStream("form-view-test.xml");
37             resources = new FormViewResources(inFomView);
38             
39         } finally {
40 // Make sure we close the input stream.
41
if (inFomView != null) {
42                 inFomView.close();
43             }
44
45         }
46
47         InputStream JavaDoc inDisplayerConfig = null;
48         // Merge with DisplayersConfigResources
49
DisplayersConfigResources displayersResources = null;
50         try {
51             
52             inDisplayerConfig = DisplayersConfigResources.class.getResourceAsStream("displayers-config.xml");
53             displayersResources = new DisplayersConfigResources(inDisplayerConfig);
54             
55         } finally {
56 // Make sure we close the input stream.
57
if (inDisplayerConfig != null) {
58                 inDisplayerConfig.close();
59             }
60         }
61         resources.mergeDisplayersWithDisplayerConfig(displayersResources);
62         
63         String JavaDoc formName = "/user/identite_collaborateur";
64         String JavaDoc state = "READ";
65         ApplicationFormViewUtil.init(resources);
66         
67         FormView form = ApplicationFormViewUtil.getFormView(formName, state);
68         //defaultBehaviour = FormViewUtil.getDefaultBehaviour(defaultState);
69

70         
71         // Test role with buttonSave
72
String JavaDoc htmlContent = getHtmlContent();
73         String JavaDoc htmlContentProcess = ApplicationFormViewUtil.processHtmlContent(form, state, null, htmlContent);
74         System.out.println(htmlContentProcess);
75         
76
77     }
78     
79     private static String JavaDoc getHtmlContent() {
80         StringBuffer JavaDoc htmlContent = new StringBuffer JavaDoc("");
81         htmlContent.append("<input name=\"htmlElementCheckBoxChecked\" type=\"checkbox\" checked=\"checked\" value=\"ValueChecked\" >\n");
82         htmlContent.append("<input name=\"htmlElementCheckBoxNotChecked\" type=\"checkbox\" value=\"ValueNotChecked\" >\n");
83         htmlContent.append("\n");
84         htmlContent.append("<input name=\"htmlElementRadioChecked\" type=\"radio\" checked=\"checked\" value=\"ValueChecked\" >\n");
85         htmlContent.append("<input name=\"htmlElementRadioChecked\" type=\"radio\" value=\"ValueChecked\" >\n");
86         htmlContent.append("\n");
87         htmlContent.append("<input name=\"htmlElementRadioNotChecked\" type=\"radio\" value=\"ValueNotChecked\" >\n");
88         return htmlContent.toString();
89     }
90     
91
92
93 }
94
Popular Tags