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.mainint.*;
10: import com.teamkonzept.webman.*;
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 COPropGroupAddPropHandler extends DefaultEventHandler
20: implements ParameterTypes, DatabaseDefaults, FrameConstants {
21: private COPropGroupAddPropHandler() {
22: }
23:
24: private static COPropGroupAddPropHandler instance = new COPropGroupAddPropHandler();
25:
26: public static COPropGroupAddPropHandler 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: // add Groups
43: TKVector addGroups = new TKVector();
44: if (params.hasMultiple(PARAMETER, "ADD_PROP_ID"))
45: addGroups = params.getVector(PARAMETER,
46: "ADD_PROP_ID");
47: else if (params.get(PARAMETER, "ADD_PROP_ID") != null)
48: addGroups.addElement(params.get(PARAMETER,
49: "ADD_PROP_ID"));
50: Enumeration addGroupsEnum = addGroups.elements();
51: while (addGroupsEnum.hasMoreElements()) {
52: String pId = (String) addGroupsEnum.nextElement();
53: TKQuery q = TKDBManager
54: .newQuery(TKDBPropGroupAddMember.class);
55: q.setQueryParams("PROP_ID", new Integer(pId));
56: q.setQueryParams("PROP_GROUP_ID", new Integer(
57: propGroupId));
58: q.execute();
59: }
60: }
61:
62: TKHTMLTemplate t = evt
63: .getPrepHTMLTemplate("f_co_propgroup.tmpl");
64: if (!propGroupId.equals("-1")) {
65: HTMLUtils.fillFrameSet(t, LEFT_FRAME_WIDTH,
66: "CO_PROPGROUP_LIST", "CO_PROPGROUP_EDIT");
67: t.set("PROPGROUP_ID", propGroupId);
68: } else
69: HTMLUtils.fillFrameSet(t, LEFT_FRAME_WIDTH,
70: "CO_PROPGROUP_LIST", "EMPTY");
71:
72: WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t,
73: CUSTOMIZE_PROPERTIES);
74: evt.finishTemplate(t);
75: } catch (Throwable e) {
76: throw WebmanExceptionHandler.getException(e);
77: }
78: }
79:
80: public boolean isHandler(TKEvent evt) {
81: return evt.getName().equalsIgnoreCase("CO_PROPGROUP_ADD_PROP");
82: }
83:
84: }
|