01: package de.webman.content.eventhandler;
02:
03: import com.teamkonzept.web.*;
04: import com.teamkonzept.webman.*;
05: import com.teamkonzept.webman.db.TKWebmanDBManager;
06: import com.teamkonzept.webman.mainint.*;
07: import com.teamkonzept.webman.mainint.db.*;
08: import com.teamkonzept.webman.mainint.db.queries.*;
09: 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 de.webman.acl.Policy;
15: import java.sql.*;
16:
17: /**
18: * modify-event bei editieren des Formulars (ContentType)
19: *
20: *
21: * @author $Author: sebastian $
22: * @version $Revision: 1.10 $
23: */
24: public class CEModifyHandler extends DefaultEventHandler implements
25: ParameterTypes, FrameConstants, DatabaseDefaults {
26: private CEModifyHandler() {
27: }
28:
29: private static CEModifyHandler instance = new CEModifyHandler();
30:
31: public static CEModifyHandler getInstance() {
32: return instance;
33: }
34:
35: public void handleEvent(TKEvent evt) throws TKException {
36: try {
37: CEUtils.checkEvent(evt);
38: TKHTMLTemplate t = evt
39: .getPrepHTMLTemplate("ce_fields.tmpl");
40:
41: ContentContext ceContext = CEUtils.keepCEContext(evt, t);
42:
43: TKFormDBData data = new TKFormDBData(ceContext.formId
44: .intValue());
45: TKFormDBInterface.Get(data);
46: TKBaseField field = TKFieldRegistry.getFieldFromDB(data);
47: TKHashtable fieldContext = new TKHashtable();
48:
49: Object realData = field.compileData("", evt.getParams()
50: .getClass(PARAMETER), fieldContext);
51: String action = evt.getParameter(ACTION, "MODIFY");
52: String target = evt.getParameter(TARGET, "MODIFY");
53:
54: t
55: .set("DESTINATION", field.modify(action, target,
56: realData));
57: // Content auf geändert setzten
58: t.set("CHANGED", new Integer(1));
59: /*
60: String dest = field.modify( action, target, realData );
61: log.println("destinatione "+dest);
62: t.set( "DESTINATION", dest );
63: */
64: field.fillIntoTemplate(t, realData, "");
65: WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t,
66: ContextConstants.CONTENT_EDIT,
67: Policy.CONTENT_TREE_ID, ceContext.conNodeId);
68:
69: evt.finishTemplate(t);
70: } catch (Throwable e) {
71: // TO DO : Analyze Exception !
72: throw WebmanExceptionHandler.getException(e);
73: }
74: }
75:
76: public boolean isHandler(TKEvent evt) {
77: return evt.getName().equalsIgnoreCase("CE_MODIFY");
78: }
79: }
|