Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 17th, 2012  |  syntax: None  |  size: 2.49 KB  |  views: 29  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.io.Serializable;
  2. import javax.enterprise.context.SessionScoped;
  3. // or import javax.faces.bean.SessionScoped;
  4. import javax.inject.Named;
  5. /* include SQL Packages */
  6. import java.sql.Connection;
  7. import java.sql.PreparedStatement;
  8. import java.sql.ResultSet;
  9. import java.sql.SQLException;
  10. import java.util.ArrayList;
  11. import java.util.HashMap;
  12. import java.util.List;
  13. import javax.annotation.PostConstruct;
  14. import javax.sql.DataSource;
  15. import javax.annotation.Resource;
  16. import javax.faces.bean.ViewScoped;
  17. import javax.faces.context.FacesContext;
  18. import javax.inject.Inject;
  19. import javax.servlet.http.HttpServletRequest;
  20. import javax.servlet.http.HttpSession;
  21. // or import javax.faces.bean.ManagedBean;  
  22.  
  23. import org.glassfish.osgicdi.OSGiService;
  24.  
  25. @Named("ApplicationController")
  26. @ViewScoped
  27. public class Application implements Serializable {
  28.  
  29.     public Application() {
  30.     }
  31.     /* Call the Oracle JDBC Connection driver */
  32.     @Resource(name = "jdbc/Oracle")
  33.     private DataSource ds;
  34.  
  35.     List<MyTabObject> tabs;
  36.    
  37.     @PostConstruct
  38.     public void init() {
  39.         tabs = new ArrayList<MyTabObject>();
  40.         tabs.add(new MyTabObject("ApplicationTabMain.xhtml", "Main"));
  41.         tabs.add(new MyTabObject("ApplicationTabModel.xhtml", "Model"));
  42.         tabs.add(new MyTabObject("ApplicationTabSettings.xhtml", "Settings"));
  43.  
  44.     }
  45.     String selectedTab = "Main";
  46.  
  47.     public String getSelectedTab() {
  48.         return selectedTab;
  49.     }
  50.  
  51.     public void setSelectedTab(String selectedTab) {
  52.         this.selectedTab = selectedTab;
  53.     }
  54.  
  55.     public String switchPages(String selTab) {
  56.         selectedTab = selTab;
  57.         return selectedTab;
  58.     }
  59.    
  60.  
  61.     public List<MyTabObject> gettabs() {
  62.         return tabs;
  63.     }
  64.  
  65.     public void setTabs(List<MyTabObject> tabs) {
  66.         this.tabs = tabs;
  67.     }
  68.  
  69.     ////
  70.    
  71.     public class MyTabObject {
  72.  
  73.         String tabfilename;
  74.         String tabid;
  75.  
  76.         public String gettabfilename() {
  77.             return tabfilename;
  78.         }
  79.  
  80.         public void settabfilename(String tabfilename) {
  81.             this.tabfilename = tabfilename;
  82.         }
  83.  
  84.         public String getTabid() {
  85.             return tabid;
  86.         }
  87.  
  88.         public void settabid(String tabid) {
  89.             this.tabid = tabid;
  90.         }
  91.  
  92.         public MyTabObject(String tabfilename, String tabid) {
  93.             super();
  94.             this.tabfilename = tabfilename;
  95.             this.tabid = tabid;
  96.         }
  97.     }
  98. }