1 24 package org.riotfamily.riot.editor; 25 26 import org.riotfamily.riot.form.ui.FormController; 27 import org.springframework.util.Assert; 28 29 30 33 public class FormDefinition extends AbstractObjectEditorDefinition 34 implements FormReference, Cloneable { 35 36 protected static final String TYPE_FORM = "form"; 37 38 private String discriminatorValue; 39 40 private String formId; 41 42 43 public FormDefinition(EditorRepository editorRepository) { 44 setEditorRepository(editorRepository); 45 } 46 47 public String getEditorType() { 48 return TYPE_FORM; 49 } 50 51 public String getFormId() { 52 return formId; 53 } 54 55 public void setId(String id) { 56 super.setId(id); 57 } 58 59 public void setFormId(String formId) { 60 this.formId = formId; 61 } 62 63 public Class getBeanClass() { 64 Assert.notNull(formId, "A formId must be set before calling getBeanClass()."); 65 return getEditorRepository().getFormRepository().getBeanClass(formId); 66 } 67 68 protected String getDefaultName() { 69 return getFormId(); 70 } 71 72 public String getDiscriminatorValue() { 73 return discriminatorValue; 74 } 75 76 public void setDiscriminatorValue(String discriminatorValue) { 77 this.discriminatorValue = discriminatorValue; 78 } 79 80 public FormDefinition copy(String idPrefix) { 81 try { 82 FormDefinition copy = (FormDefinition) clone(); 83 copy.setId(idPrefix + getId()); 84 getEditorRepository().addEditorDefinition(copy); 85 return copy; 86 } 87 catch (CloneNotSupportedException e) { 88 throw new RuntimeException (e); 89 } 90 } 91 92 protected String getEditorUrlWithinServlet(String objectId, String parentId) { 93 return FormController.getUrl(getId(), objectId, parentId); 94 } 95 96 } 97 | Popular Tags |