KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > acl > eventhandler > ACRoleEditEventHandler


1 package de.webman.acl.eventhandler;
2
3 import java.util.*;
4
5 import com.teamkonzept.web.*;
6 import com.teamkonzept.lib.*;
7 import com.teamkonzept.webman.*;
8 import com.teamkonzept.webman.mainint.*;
9 import com.teamkonzept.webman.mainint.events.*;
10 import de.webman.acl.*;
11
12 /**
13     Shows a form for changing the definition of a role
14  * @author $Author: alex $
15  * @version $Revision: 1.3 $
16  */

17 public class ACRoleEditEventHandler extends DefaultEventHandler implements ParameterTypes, DatabaseDefaults, FrameConstants
18 {
19 private ACRoleEditEventHandler() {}
20
21     private static ACRoleEditEventHandler instance = new ACRoleEditEventHandler();
22
23     public static ACRoleEditEventHandler getInstance()
24     {
25         return instance;
26     }
27
28     public void handleEvent(TKEvent evt) throws TKException
29     {
30         try {
31             WebManEvent.checkEvent(evt.getRemoteUser(), evt.getName(), ContextConstants.ACCESS_CONTROL);
32
33             String JavaDoc roleId = evt.getParameter( PARAMETER, "ROLE_ID");
34             TKHTMLTemplate t = evt.getPrepHTMLTemplate( "ac_roleedit.tmpl" );
35             Role theRole = null;
36             if (roleId != null) {
37                 theRole = RoleFactory.getInstance().getRole(new Integer JavaDoc(roleId));
38                 if (theRole != null) {
39                     t.set("ROLE_ID", theRole.getID());
40                     t.set("ROLE_NAME", theRole.getName());
41                     
42                 }
43             }
44             TKVector taskVec = ACConvenience.makeTaskList(TaskFactory.getInstance().getTasks(), theRole);
45             t.setListIterator(new TKStandardPluginIterator("AC_TASK_LIST", null, taskVec, true, t.getListIterator()));
46             String JavaDoc editPage = evt.getParameter(PARAMETER, "EDIT_PAGE");
47             t.set("EDIT_PAGE", (editPage == null ? "1" : editPage));
48             WebManEvent.fillEventsIntoTemplate(evt.getRemoteUser(), t, ACCESS_CONTROL);
49             evt.finishTemplate( t );
50         } catch (Throwable JavaDoc e) {
51             throw WebmanExceptionHandler.getException(e);
52         }
53     }
54     
55     public boolean isHandler(TKEvent evt)
56     {
57         return evt.getName().equalsIgnoreCase( "AC_ROLE_EDIT" );
58     }
59     
60 }
61
Popular Tags