KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > sitetree > eventhandler > STModifyHandler


1 package de.webman.sitetree.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 import java.util.*;
21
22 /************************************************************************
23 /**
24 * modify-event bei editieren des Formulars (ContentType)
25 *
26 *
27 */

28 public class STModifyHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
29 {
30     private STModifyHandler()
31     {}
32     
33     private static STModifyHandler instance = new STModifyHandler();
34     
35     public static STModifyHandler 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.SITE_TREE);
45             TKHTMLTemplate t = evt.getPrepHTMLTemplate( "st_fields.tmpl" );
46             int formId = Integer.parseInt( evt.getParameter( PARAMETER, "FORM_ID" ) );
47             TKFormDBData data = new TKFormDBData( formId, STRUCTURE_FORM_TYPE );
48             TKFormDBInterface.Get( data );
49             TKBaseField field = TKFieldRegistry.getFieldFromDB( data );
50             TKHashtable fieldContext = new TKHashtable();
51
52             Object JavaDoc realData = field.compileData( "", evt.getParams().getClass( PARAMETER ), fieldContext );
53             String JavaDoc action = evt.getParameter( ACTION, "MODIFY" );
54             String JavaDoc target = evt.getParameter( TARGET, "MODIFY" );
55             t.set( "DESTINATION", field.modify( action, target, realData ) );
56             field.fillIntoTemplate( t, realData, "" );
57
58             SiteTreeUtils.keepSTContext( evt, t );
59             WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, SITE_TREE);
60             evt.finishTemplate(t);
61         }
62         catch (Throwable JavaDoc e)
63         {
64             // TO DO : Analyze Exception !
65
throw WebmanExceptionHandler.getException(e);
66         }
67     }
68     
69     public boolean isHandler(TKEvent evt)
70     {
71         return evt.getName().equalsIgnoreCase("ST_MODIFY");
72     }
73 }
74
Popular Tags