KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > config > eventhandler > COPropGroupDelPropHandler


1 package de.webman.config.eventhandler;
2
3 import java.util.*;
4 import java.sql.*;
5
6 import com.teamkonzept.web.*;
7 import com.teamkonzept.lib.*;
8 import com.teamkonzept.db.*;
9 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 implements ParameterTypes, DatabaseDefaults, FrameConstants
20 {
21     private COPropGroupDelPropHandler() {}
22     
23     private static COPropGroupDelPropHandler instance = new COPropGroupDelPropHandler();
24     
25     public static COPropGroupDelPropHandler getInstance()
26     {
27         return instance;
28     }
29
30     public void handleEvent(TKEvent evt) throws TKException
31     {
32         try {
33             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.CUSTOMIZE_PROPERTIES); // check if event is allowed
34
String JavaDoc propGroupId = evt.getParameter(PARAMETER, "PROPGROUP_ID");
35             
36             propGroupId = (propGroupId != null ? propGroupId : "-1");
37
38             // set the group membership
39
if ( ! propGroupId.equals("-1") ) {
40                 TKParams params = evt.getParams();
41
42                 // delete Groups
43
TKVector delGroups = new TKVector();
44                 if ( params.hasMultiple( PARAMETER, "DEL_PROP_ID" ))
45                 {
46                     delGroups = params.getVector( PARAMETER, "DEL_PROP_ID" );
47                 }
48                 else if ( params.get( PARAMETER, "DEL_PROP_ID" ) != null )
49                 {
50                     delGroups.addElement( params.get( PARAMETER, "DEL_PROP_ID" ));
51                 }
52                 Enumeration delGroupsEnum = delGroups.elements();
53                 while (delGroupsEnum.hasMoreElements()) {
54                     String JavaDoc pId = (String JavaDoc)delGroupsEnum.nextElement();
55                     TKQuery q = TKDBManager.newQuery(TKDBPropGroupRemoveMember.class);
56                     q.setQueryParams( "PROP_ID", new Integer JavaDoc(pId) );
57                     q.setQueryParams( "PROP_GROUP_ID", new Integer JavaDoc(propGroupId) );
58                     q.execute();
59                 }
60             }
61
62             TKHTMLTemplate t = evt.getPrepHTMLTemplate( "f_co_propgroup.tmpl" );
63             if ( ! propGroupId.equals("-1") )
64             {
65                 HTMLUtils.fillFrameSet( t, LEFT_FRAME_WIDTH, "CO_PROPGROUP_LIST", "CO_PROPGROUP_EDIT" );
66                 t.set("PROPGROUP_ID", propGroupId);
67             }
68             else
69             {
70                 HTMLUtils.fillFrameSet( t, LEFT_FRAME_WIDTH, "CO_PROPGROUP_LIST", "EMPTY" );
71             }
72             
73             WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, CUSTOMIZE_PROPERTIES);
74             evt.finishTemplate( t );
75         } catch (Throwable JavaDoc e) {
76             throw WebmanExceptionHandler.getException(e);
77         }
78     }
79     
80     public boolean isHandler(TKEvent evt)
81     {
82         return evt.getName().equalsIgnoreCase( "CO_PROPGROUP_DEL_PROP" );
83     }
84
85 }
86
Popular Tags