1 package de.webman.form.eventhandler; 2 3 import com.teamkonzept.web.*; 4 import com.teamkonzept.webman.*; 5 import com.teamkonzept.webman.db.TKWebmanDBManager; 6 import com.teamkonzept.webman.mainint.*; 7 import com.teamkonzept.webman.mainint.db.*; 8 import com.teamkonzept.webman.mainint.db.queries.*; 9 import com.teamkonzept.webman.mainint.events.*; 10 import com.teamkonzept.lib.*; 11 import com.teamkonzept.field.*; 12 import com.teamkonzept.field.db.*; 13 import com.teamkonzept.db.*; 14 import com.teamkonzept.publishing.markups.*; 15 import de.webman.form.Form; 16 17 23 public class CTDuplicateHandler 24 extends DefaultEventHandler 25 implements ParameterTypes, 26 FrameConstants, 27 DatabaseDefaults 28 { 29 30 33 private static final CTDuplicateHandler INSTANCE = new CTDuplicateHandler(); 34 35 38 private CTDuplicateHandler() 39 { 40 } 42 43 48 public static CTDuplicateHandler getInstance () 49 { 50 return INSTANCE; 51 } 52 53 59 public void handleEvent (TKEvent event) 60 throws TKException 61 { 62 try 63 { 64 WebManEvent.checkEvent(event.getRemoteUser(), event.getName(), ContextConstants.CONTENT_TREE); 66 67 Form form = new Form(Integer.valueOf(event.getParameter(PARAMETER, "FORM_ID"))); 69 70 TKHTMLTemplate t = event.getPrepHTMLTemplate("ct_dupForm.tmpl"); 72 73 t.set("FORM_ID", form.getIdentifier()); 75 t.set("FORM_NAME", form.getDescription()); 76 77 if (form.isFormFragment()) 78 { 79 String name = event.getParameter(PARAMETER, "NEW_FORM_NAME"); 80 t.set("NEW_FORM_NAME", (name != null && name.length() > 0) ? name : form.getName()); 81 } 82 83 String description = event.getParameter(PARAMETER, "NEW_FORM_DESCRIPTION"); 84 t.set("NEW_FORM_DESCRIPTION", (description != null && description.length() > 0) ? description : form.getDescription()); 85 86 if (event.getParameter(PARAMETER, "ERROR") != null) 87 { 88 t.set("ERROR", event.getParameter(PARAMETER, "ERROR")); 89 } 90 91 WebManEvent.fillEventsIntoTemplate(event.getRemoteUser(), t, CONTENT_TREE); 93 event.finishTemplate(t); 94 } 95 catch (Throwable e) 96 { 97 throw WebmanExceptionHandler.getException(e); 99 } 100 } 101 102 109 public boolean isHandler (TKEvent event) 110 { 111 return event.getName().equalsIgnoreCase("CT_DUPLICATE"); 112 } 113 114 } 115 | Popular Tags |