KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > documenttype > eventhandler > DTSavePresHandler


1 package de.webman.documenttype.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 * doPRSavePres
23 *
24 * Speichern einer Presentation
25 * danach linke Liste neu, rechts leere Liste aller Componenten dieser Presentation
26 *
27  * @author $Author: alex $
28  * @version $Revision: 1.4 $
29 */

30 public class DTSavePresHandler extends DefaultEventHandler implements ParameterTypes, FrameConstants, DatabaseDefaults
31 {
32     private DTSavePresHandler()
33     {}
34
35     /** Singleton Instanz */
36     private static DTSavePresHandler instance = new DTSavePresHandler();
37     
38     public static DTSavePresHandler getInstance()
39     {
40         return instance;
41     }
42     
43     public void handleEvent(TKEvent evt) throws TKException
44     {
45         try
46         {
47             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.PRESENTATIONS);
48             String JavaDoc tmplId = evt.getParameter( PARAMETER, "THE_TEMPLATE_ID" );
49             if (tmplId == null || tmplId.equals(""))
50             {
51                 throw new TKUserException("Es muß ein Template angelegt werden", NO_TEMPLATE_DEFINED, USER_SEVERITY, false,null);
52             }
53             String JavaDoc presId = "";
54             String JavaDoc name = evt.getNotNullParameter( PARAMETER, "PRESENTATION_NAME" ).trim();
55             String JavaDoc shortName = evt.getNotNullParameter( PARAMETER, "PRESENTATION_SHORTNAME" ).trim();
56             if (name.equals(""))
57                 throw new TKUserException("Name des Dokumententyps darf nicht leer sein", INPUT_CANNOT_BE_EMPTY, USER_SEVERITY, false, null);
58             if (shortName.equals(""))
59                 throw new TKUserException("Kennung des Dokumententyps darf nicht leer sein", INPUT_CANNOT_BE_EMPTY, USER_SEVERITY, false, null);
60             TKQuery q = TKDBManager.newQuery(TKDBPresInsert.class);
61             q.setQueryParams( "PRESENTATION_NAME", name );
62             q.setQueryParams( "PRESENTATION_SHORTNAME", shortName);
63             q.setQueryParams( "TEMPLATE_ID", new Integer JavaDoc( tmplId ) );
64             q.execute();
65             ResultSet rs = q.fetchResultSet();
66             if( rs.next() ) {
67                 presId = Integer.toString( rs.getInt( "PRESENTATION_ID" ) );
68             }
69
70             TKHTMLTemplate frame = evt.getPrepHTMLTemplate( "f_pr.tmpl" );
71             HTMLUtils.fillFrameSet( frame, LEFT_FRAME_WIDTH_SMALL, "PR_SHOWLIST", "PR_EDIT" );
72             frame.set( evt.getParams().getClass( PARAMETER ) );
73             frame.set( "TEMPLATE_ID", tmplId );
74             frame.set( "PRESENTATION_ID", presId );
75             frame.set( "DESTINATION", presId );
76             WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), frame, PRESENTATIONS);
77             evt.finishTemplate(frame);
78         }
79         catch (Throwable JavaDoc e)
80         {
81             // TO DO : Analyze Exception !
82
throw WebmanExceptionHandler.getException(e);
83         }
84     }
85     
86     public boolean isHandler(TKEvent evt)
87     {
88         return evt.getName().equalsIgnoreCase("PR_SAVE_PRES") ;
89     }
90 }
91
Popular Tags