01: package de.webman.config.eventhandler;
02:
03: import java.util.*;
04: import java.sql.*;
05:
06: import com.teamkonzept.web.*;
07: import com.teamkonzept.lib.*;
08: import com.teamkonzept.db.*;
09: import com.teamkonzept.webman.*;
10: import com.teamkonzept.webman.mainint.*;
11: import com.teamkonzept.webman.mainint.db.queries.*;
12: import com.teamkonzept.webman.mainint.events.*;
13:
14: /**
15: Displays a frameset with a list of users on the left and an empty page to the right
16: * @author $Author: alex $
17: * @version $Revision: 1.2 $
18: */
19: public class COPropGroupDelPropHandler extends DefaultEventHandler
20: implements ParameterTypes, DatabaseDefaults, FrameConstants {
21: private COPropGroupDelPropHandler() {
22: }
23:
24: private static COPropGroupDelPropHandler instance = new COPropGroupDelPropHandler();
25:
26: public static COPropGroupDelPropHandler getInstance() {
27: return instance;
28: }
29:
30: public void handleEvent(TKEvent evt) throws TKException {
31: try {
32: WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(),
33: ContextConstants.CUSTOMIZE_PROPERTIES); // check if event is allowed
34: String propGroupId = evt.getParameter(PARAMETER,
35: "PROPGROUP_ID");
36:
37: propGroupId = (propGroupId != null ? propGroupId : "-1");
38:
39: // set the group membership
40: if (!propGroupId.equals("-1")) {
41: TKParams params = evt.getParams();
42:
43: // delete Groups
44: TKVector delGroups = new TKVector();
45: if (params.hasMultiple(PARAMETER, "DEL_PROP_ID")) {
46: delGroups = params.getVector(PARAMETER,
47: "DEL_PROP_ID");
48: } else if (params.get(PARAMETER, "DEL_PROP_ID") != null) {
49: delGroups.addElement(params.get(PARAMETER,
50: "DEL_PROP_ID"));
51: }
52: Enumeration delGroupsEnum = delGroups.elements();
53: while (delGroupsEnum.hasMoreElements()) {
54: String pId = (String) delGroupsEnum.nextElement();
55: TKQuery q = TKDBManager
56: .newQuery(TKDBPropGroupRemoveMember.class);
57: q.setQueryParams("PROP_ID", new Integer(pId));
58: q.setQueryParams("PROP_GROUP_ID", new Integer(
59: propGroupId));
60: q.execute();
61: }
62: }
63:
64: TKHTMLTemplate t = evt
65: .getPrepHTMLTemplate("f_co_propgroup.tmpl");
66: if (!propGroupId.equals("-1")) {
67: HTMLUtils.fillFrameSet(t, LEFT_FRAME_WIDTH,
68: "CO_PROPGROUP_LIST", "CO_PROPGROUP_EDIT");
69: t.set("PROPGROUP_ID", propGroupId);
70: } else {
71: HTMLUtils.fillFrameSet(t, LEFT_FRAME_WIDTH,
72: "CO_PROPGROUP_LIST", "EMPTY");
73: }
74:
75: WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t,
76: CUSTOMIZE_PROPERTIES);
77: evt.finishTemplate(t);
78: } catch (Throwable e) {
79: throw WebmanExceptionHandler.getException(e);
80: }
81: }
82:
83: public boolean isHandler(TKEvent evt) {
84: return evt.getName().equalsIgnoreCase("CO_PROPGROUP_DEL_PROP");
85: }
86:
87: }
|