KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > content > eventhandler > CEModifyHandler


1 package de.webman.content.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 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 ParameterTypes, FrameConstants, DatabaseDefaults
25 {
26     private CEModifyHandler()
27     {}
28     
29     private static CEModifyHandler instance = new CEModifyHandler();
30     
31     public static CEModifyHandler getInstance()
32     {
33         return instance;
34     }
35     
36     public void handleEvent(TKEvent evt) throws TKException
37     {
38         try
39         {
40             CEUtils.checkEvent(evt);
41             TKHTMLTemplate t = evt.getPrepHTMLTemplate( "ce_fields.tmpl" );
42             
43             ContentContext ceContext = CEUtils.keepCEContext(evt, t );
44
45             TKFormDBData data = new TKFormDBData( ceContext.formId.intValue() );
46             TKFormDBInterface.Get( data );
47             TKBaseField field = TKFieldRegistry.getFieldFromDB( data );
48             TKHashtable fieldContext = new TKHashtable();
49
50             Object JavaDoc realData = field.compileData( "", evt.getParams().getClass( PARAMETER ), fieldContext );
51             String JavaDoc action = evt.getParameter( ACTION, "MODIFY" );
52             String JavaDoc target = evt.getParameter( TARGET, "MODIFY" );
53
54             t.set( "DESTINATION", field.modify( action, target, realData ) );
55             // Content auf gešndert setzten
56
t.set( "CHANGED",new Integer JavaDoc(1));
57             /*
58             String dest = field.modify( action, target, realData );
59             log.println("destinatione "+dest);
60             t.set( "DESTINATION", dest );
61             */

62             field.fillIntoTemplate( t, realData, "" );
63             WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, ContextConstants.CONTENT_EDIT, Policy.CONTENT_TREE_ID, ceContext.conNodeId);
64             
65             evt.finishTemplate(t);
66         }
67         catch (Throwable JavaDoc e)
68         {
69             // TO DO : Analyze Exception !
70
throw WebmanExceptionHandler.getException(e);
71         }
72     }
73     
74     public boolean isHandler(TKEvent evt)
75     {
76         return evt.getName().equalsIgnoreCase("CE_MODIFY");
77     }
78 }
79
Popular Tags