1 20 package org.enhydra.barracuda.contrib.dbroggisch.examples.model.forms; 21 22 import org.enhydra.barracuda.contrib.dbroggisch.repopulation.*; 23 import org.enhydra.barracuda.core.forms.*; 24 import org.enhydra.barracuda.core.comp.*; 25 import org.enhydra.barracuda.core.forms.validators.*; 26 27 public class ExampleFormMap extends RepopulationFormMap { 28 29 public final static String MODEL_NAME = "ExampleModel"; 30 public final static String GROUP = "GROUP"; 31 public final static String CHECKBOX = "CHECKBOX"; 32 public final static String SELECT = "SELECT"; 33 public final static String TEXTAREA = "TEXTAREA"; 34 public final static String SIMPLECHECKBOX = "SIMPLECHECKBOX"; 35 public ExampleFormMap() { 36 setName(MODEL_NAME); 37 defineElement(new GroupFormElement( 42 new TestList(), 43 GROUP, 44 FormType.INTEGER, 45 null, 46 new And(new SelectFormValidator(), new NotNullValidator()), 47 false)); 48 49 defineElement(new GroupFormElement( 52 new TestList(), 53 CHECKBOX, 54 FormType.INTEGER, 55 null, 56 new And(new SelectFormValidator(), new NotNullValidator()), 57 true)); 58 59 defineElement(new SelectFormElement( 60 new TestList(), 61 SELECT, 62 FormType.INTEGER, 63 null, 64 new SelectFormValidator("Element no. " + 0, "You're not allowed to select the first element!"), 65 false)); 66 67 defineElement(new TextAreaFormElement( 68 TEXTAREA, 69 null, 70 null)); 71 72 defineElement(new CheckboxFormElement(SIMPLECHECKBOX, 73 FormType.BOOLEAN)); 74 75 } 76 77 public static class TestList extends DefaultListModel { 78 79 public TestList() { 80 for(int i = 0; i < 5; i++) { 81 add(new DefaultItemMap("" + i, "Element no. " + i)); 82 } 83 } 84 } 85 } 86 | Popular Tags |