01: package de.webman.documenttype.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:
09: import com.teamkonzept.webman.mainint.db.queries.*;
10: import com.teamkonzept.webman.mainint.events.*;
11: import com.teamkonzept.lib.*;
12: import com.teamkonzept.field.*;
13: import com.teamkonzept.field.db.*;
14: import com.teamkonzept.db.*;
15: import com.teamkonzept.publishing.markups.*;
16:
17: import java.util.*;
18: import java.sql.*;
19:
20: /************************************************************************
21: /**
22: * doPREditSubpresSel
23: *
24: * Aendern der sub_presentation-Auswahl einer typedReference-Componente einer Presentation
25: *
26: */
27: public class DTEditSubPresSelectionHandler extends DefaultEventHandler
28: implements ParameterTypes, FrameConstants, DatabaseDefaults {
29: private DTEditSubPresSelectionHandler() {
30: }
31:
32: private static DTEditSubPresSelectionHandler instance = new DTEditSubPresSelectionHandler();
33:
34: public static DTEditSubPresSelectionHandler getInstance() {
35: return instance;
36: }
37:
38: public void handleEvent(TKEvent evt) throws TKException {
39: try {
40: WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(),
41: ContextConstants.PRESENTATIONS);
42: TKHTMLTemplate t = evt
43: .getPrepHTMLTemplate("pr_compSelect.tmpl");
44: TKQuery q = TKDBManager.newQuery(TKDBPresentationGet.class);
45: q.execute();
46: ResultSet rs = q.fetchResultSet();
47: TKDBTemplate
48: .prepareListTemplate(rs, t, "PR_SELECTION_LIST");
49: t.set(evt.getParams().getClass(PARAMETER));
50: TKVector subPresSelection = DTUtils.getSelectedPres(evt);
51: if (subPresSelection.size() != 0) {
52: t.set("SUB_PRESENTATION_ID",
53: subPresSelection.size() > 1 ? subPresSelection
54: : subPresSelection.get(0));
55: TKStandardIterator iterator = new TKStandardIterator(
56: subPresSelection, t.getListIterator(),
57: "PR_OLD_SELECTION_LIST",
58: "OLD_SUB_PRESENTATION_ID");
59: t.setListIterator(iterator);
60: }
61: WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t,
62: PRESENTATIONS);
63: evt.finishTemplate(t);
64: } catch (Throwable e) {
65: // TO DO : Analyze Exception !
66: throw WebmanExceptionHandler.getException(e);
67: }
68: }
69:
70: public boolean isHandler(TKEvent evt) {
71: return evt.getName().equalsIgnoreCase(
72: "PR_EDIT_SUBPRES_SELECTION");
73: }
74: }
|