Advertisement
Metrowy

GatunekListBB

Mar 25th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. package com.audio.admin;
  2.  
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import java.util.ResourceBundle;
  7.  
  8. import javax.annotation.PostConstruct;
  9. import javax.ejb.EJB;
  10. import javax.faces.application.FacesMessage;
  11. import javax.faces.bean.ManagedBean;
  12. import javax.faces.context.FacesContext;
  13. import javax.faces.simplesecurity.RemoteClient;
  14. import javax.servlet.http.HttpSession;
  15.  
  16. import com.audio.dao.GatunekDAO;
  17. import com.audio.entities.Gatunek;
  18.  
  19. @ManagedBean
  20. public class GatunekListBB {
  21. private static final String PAGE_GENRE_EDIT = "/pages/admin/gatunek?faces-redirect=true";
  22. private static final String PAGE_STAY_AT_THE_SAME = null;
  23.  
  24. private String name;
  25. private ResourceBundle messages;
  26.  
  27. public String getName() {
  28. return name;
  29. }
  30. public void setName(String name) {
  31. this.name = name;
  32. }
  33.  
  34. @EJB
  35. GatunekDAO gatunekDAO;
  36.  
  37. @PostConstruct
  38. public void initialization()
  39. {
  40. FacesContext context = FacesContext.getCurrentInstance();
  41. messages = ResourceBundle.getBundle("resources.gatunekBean", context.getViewRoot().getLocale());
  42. }
  43.  
  44. public List<Gatunek> getFullList()
  45. {
  46. return gatunekDAO.getFullList();
  47. }
  48.  
  49. public List<Gatunek> getList()
  50. {
  51. List<Gatunek> list = null;
  52.  
  53. Map<String, Object> searchParams = new HashMap<String, Object>();
  54.  
  55. if(name != null && name.length() > 0)
  56. {
  57. searchParams.put("name", name);
  58. }
  59.  
  60. list = gatunekDAO.getList(searchParams);
  61.  
  62. return list;
  63. }
  64.  
  65. public String newGatunek()
  66. {
  67. HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
  68. .getExternalContext().getSession(true);
  69. Gatunek gatunek = new Gatunek();
  70. session.setAttribute("gatunek", gatunek);
  71. return PAGE_GENRE_EDIT;
  72. }
  73.  
  74. public String deleteGatunek(Gatunek gatunek)
  75. {
  76. gatunekDAO.remove(gatunek);
  77. return PAGE_STAY_AT_THE_SAME;
  78. }
  79.  
  80.  
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement