View Javadoc

1   package org.paneris.jal.controller;
2   
3   import org.paneris.jal.model.DBConnectionManager;
4   import org.webmacro.Template;
5   import org.webmacro.servlet.HandlerException;
6   import org.webmacro.servlet.PanerisPage;
7   import org.webmacro.servlet.WebContext;
8   
9   
10  /**
11   * Return a page of available databases.
12   */ 
13  public class AdministrationDatasources extends PanerisPage {
14  
15    private static final long serialVersionUID = 1L;
16      private DBConnectionManager connMgr =  DBConnectionManager.getInstance();
17  
18  /**
19   *
20   * @return          Template 
21   * @exception       org.webmacro.servlet.HandlerException Cannot Connect to DB
22   * @exception       org.webmacro.servlet.HandlerException Cannot find templates
23   **/
24  
25      public Template handle(WebContext context) throws HandlerException {
26          context.put("datasources",connMgr.getPools());
27          // return the appropriate template
28  
29          String templateName = (String) context.getForm("wmtemplate");
30          if (templateName == null) templateName = "jal/view/AdministrationDatasources.wm";
31          context.put("wmtemplate",templateName);
32          try {
33              return (Template) context.getBroker().get("template",templateName);
34          } catch (Exception e) {
35              throw new HandlerException("Could not locate template: " + templateName);
36          }
37      }
38  
39  }
40