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.util.ApplicationFormViewUtil; 11 12 import org.xml.sax.SAXException ; 13 14 public class FormViewTestSelectMultiple { 15 16 19 public static void main(String [] args) 20 throws FormViewException, IOException , SAXException { 21 InputStream inFomView = null; 22 23 24 FormViewResources resources = null; 26 try { 27 28 34 inFomView = FormViewTest.class.getResourceAsStream("form-view-test.xml"); 35 resources = new FormViewResources(inFomView); 36 37 } finally { 38 if (inFomView != null) { 40 inFomView.close(); 41 } 42 43 } 44 45 InputStream inDisplayerConfig = null; 46 DisplayersConfigResources displayersResources = null; 48 try { 49 50 inDisplayerConfig = DisplayersConfigResources.class.getResourceAsStream("displayers-config.xml"); 51 displayersResources = new DisplayersConfigResources(inDisplayerConfig); 52 53 } finally { 54 if (inDisplayerConfig != null) { 56 inDisplayerConfig.close(); 57 } 58 } 59 resources.mergeDisplayersWithDisplayerConfig(displayersResources); 60 61 String formName = "/user/identite_collaborateur"; 62 String state = "READ"; 63 ApplicationFormViewUtil.init(resources); 64 65 FormView form = ApplicationFormViewUtil.getFormView(formName, state); 66 68 69 String htmlContent = getHtmlContent(); 71 String htmlContentProcess = ApplicationFormViewUtil.processHtmlContent(form, state, null, htmlContent); 72 System.out.println(htmlContentProcess); 73 74 75 } 76 77 private static String getHtmlContent() { 78 StringBuffer htmlContent = new StringBuffer (""); 79 htmlContent.append("<select name=\"HTMLSelect\" multiple=\"multiple\" >\n"); 80 for (int i=0; i< 10; i++) { 81 String selected = ""; 82 if (i<5) { 83 selected = "selected=\"selected\""; 84 } 85 86 htmlContent.append("<option value=\"HTMLSelect value " + i + "\" " + selected + " >HTMLSelect label " + i + "</option>\n"); 87 } 88 htmlContent.append("</select>\n"); 89 return htmlContent.toString(); 90 } 91 92 93 } 94 | Popular Tags |