KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > form > eventhandler > CTModifyHandler


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 com.teamkonzept.international.LanguageManager;
16
17 /**
18  * Modifes either a new or an existing form.
19  *
20  * @author $Author: uli $
21  * @version $Revision: 1.7 $
22  */

23 public class CTModifyHandler
24     extends DefaultEventHandler
25     implements ParameterTypes,
26                FrameConstants,
27                DatabaseDefaults
28 {
29
30     /**
31      * The singleton instance.
32      */

33     private static final CTModifyHandler INSTANCE = new CTModifyHandler();
34
35     /**
36      * Avoids outside instantiation.
37      */

38     private CTModifyHandler ()
39     {
40         // NOP
41
}
42
43     /**
44      * Returns the singleton instance.
45      *
46      * @return the singleton instance.
47      */

48     public static CTModifyHandler getInstance ()
49     {
50         return INSTANCE;
51     }
52
53     /**
54      * Handles the specified event.
55      *
56      * @param event the event to be handled.
57      * @throws TKException if any error occurred during event handling.
58      */

59     public void handleEvent (TKEvent event)
60         throws TKException
61     {
62         try
63         {
64             // Check event.
65
WebManEvent.checkEvent(event.getRemoteUser(), event.getName(), CONTENT_TREE);
66
67             // Get form prototype from submitted form data.
68
TKBaseField field = CTUtils.getStructure(Integer.parseInt(event.getParameter(PARAMETER, "FORM_TYPE")));
69             Object JavaDoc realData = field.compileData("", event.getParams().getClass(PARAMETER), new TKHashtable());
70             String JavaDoc action = event.getParameter(ACTION, "MODIFY");
71             String JavaDoc target = event.getParameter(TARGET, "MODIFY");
72
73             // Finish event.
74
TKHTMLTemplate t = event.getPrepHTMLTemplate("ct_fields.tmpl");
75             field.fillIntoTemplate(t, realData, "");
76             t.set("DESTINATION", field.modify(action, target, realData));
77             CTUtils.keepCTContext(event, t);
78             WebManEvent.fillEventsIntoTemplate(event.getRemoteUser(), t, CONTENT_TREE);
79             event.finishTemplate(t);
80         }
81         catch (Throwable JavaDoc e)
82         {
83             // TO DO : Analyze Exception !
84
throw WebmanExceptionHandler.getException(e);
85         }
86     }
87
88     /**
89      * Checks wether this handler is capable to handle the specified event.
90      *
91      * @param event the event to be handled.
92      * @return <CODE>true</CODE> if this handler is capable to handle the
93      * specified event, otherwise <CODE>false</CODE>.
94      */

95     public boolean isHandler (TKEvent event)
96     {
97         return event.getName().equalsIgnoreCase("CT_MODIFY");
98     }
99
100 }
101
Popular Tags