1 package org.paneris.user.controller;
2
3 import org.paneris.jal.model.DBConnectionManager;
4 import org.paneris.user.model.User;
5 import org.webmacro.Template;
6 import org.webmacro.servlet.HandlerException;
7 import org.webmacro.servlet.PanerisPage;
8 import org.webmacro.servlet.WebContext;
9
10
11
12
13
14
15 public class DisplayUser extends PanerisPage {
16
17 private static final long serialVersionUID = 1L;
18 DBConnectionManager connMgr = DBConnectionManager.getInstance();
19
20 public Template handle(WebContext context) throws HandlerException {
21 String db = (String) context.getForm("db");
22 if (db == null) db = "paneris";
23 context.put("db",db);
24 String id = (String) context.getForm("id");
25 String templateName = null;
26 try {
27 if (id == null) {
28 User user = User.getInstance(context);
29 if (user == null || !user.isLoggedOn()) {
30 templateName = User.getLoginPage(context," view your details.");
31 User.setReturnURL(context);
32 } else {
33 id = user.getFieldValue("id");
34 }
35 }
36 if (templateName == null) {
37 templateName = (String) context.getForm("wmtemplate");
38 if (templateName == null) templateName = "paneris/view/User.wm";
39 context.put("ddtable", new User(db,new Integer(id)));
40 }
41 } catch (Exception e) {
42 throw new HandlerException("Could not create user: " + id);
43 }
44
45 try {
46 return (Template) context.getBroker().get("template",templateName);
47 } catch (Exception e) {
48 throw new HandlerException("Could not locate template: " + templateName);
49 }
50 }
51 }