1 package net.sourceforge.formview.test; 2 3 import java.io.IOException ; 4 import java.io.InputStream ; 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 ; 15 16 public class FormViewTestIfCondition { 17 18 21 public static void main(String [] args) 22 throws FormViewException, IOException , SAXException { 23 InputStream inFomView = null; 24 25 26 FormViewResources resources = null; 28 try { 29 30 36 inFomView = FormViewTest.class.getResourceAsStream("form-view-test.xml"); 37 resources = new FormViewResources(inFomView); 38 39 } finally { 40 if (inFomView != null) { 42 inFomView.close(); 43 } 44 45 } 46 47 InputStream inDisplayerConfig = null; 48 DisplayersConfigResources displayersResources = null; 50 try { 51 52 inDisplayerConfig = DisplayersConfigResources.class.getResourceAsStream("displayers-config.xml"); 53 displayersResources = new DisplayersConfigResources(inDisplayerConfig); 54 55 } finally { 56 if (inDisplayerConfig != null) { 58 inDisplayerConfig.close(); 59 } 60 } 61 resources.mergeDisplayersWithDisplayerConfig(displayersResources); 62 63 String formName = "/user/identite_collaborateur"; 64 String state = "READ"; 65 ApplicationFormViewUtil.init(resources); 66 67 FormView form = ApplicationFormViewUtil.getFormView(formName, state); 68 70 71 String htmlContent = getHtmlContent(); 73 String htmlContentProcess = ApplicationFormViewUtil.processHtmlContent(form, state, null, htmlContent); 74 System.out.println(htmlContentProcess); 75 76 77 } 78 79 private static String getHtmlContent() { 80 StringBuffer htmlContent = new StringBuffer (""); 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 |