KickJava   Java API By Example, From Geeks To Geeks.

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


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
9
10 import com.teamkonzept.webman.mainint.db.queries.*;
11 import com.teamkonzept.webman.mainint.events.*;
12 import com.teamkonzept.lib.*;
13 import com.teamkonzept.field.*;
14 import com.teamkonzept.field.db.*;
15 import com.teamkonzept.db.*;
16 import com.teamkonzept.publishing.markups.*;
17
18 import java.sql.*;
19 import java.io.*;
20
21 /************************************************************************
22 /**
23 * modify-event bei Testen des ContentType
24 *
25 *
26 */

27 public class CTTestModifyHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
28 {
29     
30     private CTTestModifyHandler()
31     {}
32     
33     private static CTTestModifyHandler instance = new CTTestModifyHandler();
34     
35     public static CTTestModifyHandler getInstance()
36     {
37         return instance;
38     }
39     
40     public void handleEvent(TKEvent evt) throws TKException
41     {
42         try
43         {
44             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.CONTENT_TREE);
45             TKHTMLTemplate t = evt.getPrepHTMLTemplate( "ct_fields.tmpl" );
46             String JavaDoc sConForm = evt.getParameter( PARAMETER, "TMP_FORM_ID" );
47             int conForm = Integer.parseInt( sConForm );
48             TKFormDBData data = new TKFormDBData( conForm, Integer.parseInt( evt.getParameter( PARAMETER, "FORM_TYPE" ) ) );
49             TKFormDBInterface.Get( data );
50             TKBaseField field = TKFieldRegistry.getFieldFromDB( data ); // editfield als field aus der DB
51
TKHashtable fieldContext = new TKHashtable();
52
53             Object JavaDoc realData = field.compileData( "", evt.getParams().getClass( PARAMETER ), fieldContext );
54             String JavaDoc action = evt.getParameter( ACTION, "MODIFY" );
55             String JavaDoc target = evt.getParameter( TARGET, "MODIFY" );
56             t.set( "DESTINATION", field.modify( action, target, realData ) );
57             field.fillIntoTemplate( t, realData, "" );
58
59             CTUtils.keepCTContext( evt, t );
60             WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, CONTENT_TREE);
61             evt.finishTemplate(t);
62         }
63         catch (Throwable JavaDoc e)
64         {
65             // TO DO : Analyze Exception !
66
throw WebmanExceptionHandler.getException(e);
67         }
68     }
69     
70     public boolean isHandler(TKEvent evt)
71     {
72         return evt.getName().equalsIgnoreCase("CTTEST_MODIFY");
73     }
74 }
75
Popular Tags