Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.76 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml"
  4. xmlns:h="http://xmlns.jcp.org/jsf/html"
  5. xmlns:p="http://primefaces.org/ui"
  6. xmlns:f="http://java.sun.com/jsf/core"
  7. xmlns:pm="http://primefaces.org/mobile"
  8. xmlns:ui="http://java.sun.com/jsf/facelets">
  9.  
  10. <h:head>
  11.  
  12. <!-- <link rel="stylesheet" type="text/css" href="generalstyle.css" /> -->
  13. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  14. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  15. <meta name="apple-mobile-web-app-capable" content="yes" />
  16. <meta name="apple-mobile-web-app-status-bar-style" content="black" />
  17. <link rel="apple-touch-icon" href="../images/TBT-Icon.png" />
  18.  
  19. <style type="text/css">
  20.  
  21. </style>
  22. </h:head>
  23. <h:body>
  24. <p:growl id="growl" life="3000" showDetail="true" />
  25. <h:form action="#{verifyCredentials.checkCredentials}" method="POST">
  26.  
  27. <div id="form">
  28.  
  29.  
  30. <p:fieldset legend="Teilnehmer-Beurteilungstool">
  31. <p>
  32. <pm:field>
  33. <p:outputLabel for="basic" value="Benutzername:" id="basiclabel" />
  34. <br />
  35. <p:tooltip for="basic" value="Geben Sie Ihren Login Namen ein." id="basictooltip"/>
  36. <p:inputText id="basic" value="#{verifyCredentials.kursleiter.name}" autocomplete="on" sticky="true" />
  37. <p:watermark for="basic" value="Login Namen" id="basicwatermark"/>
  38. </pm:field>
  39. </p>
  40. <p>
  41. <pm:field>
  42. <p:outputLabel for="password" value="Passwort:" id="passwordlabel"/>
  43. <br />
  44. <p:tooltip for="password" value="Geben Sie Ihr Passwort ein." id="passwordtooltip"/>
  45. <p:password required="true" id="password" value="#{verifyCredentials.kursleiter.passwort}" sticky="true" update="growl"/>
  46. <p:watermark for="password" value="Passwort" id="passwordwatermark"/>
  47. </pm:field>
  48. </p>
  49. <p>
  50. <p:tooltip for="log" value="Einloggen." id="logtooltip"/>
  51. <p:commandButton id="log" value="Login" type="submit" action="#{verifyCredentials.checkCredentials}" update="growl"/>
  52. </p>
  53.  
  54. </p:fieldset>
  55. </div>
  56. </h:form>
  57. </h:body>
  58.  
  59. </html>
  60.  
  61. package com.ubs.tbt.login;
  62.  
  63. import javax.faces.application.FacesMessage;
  64. import javax.faces.bean.ManagedBean;
  65. import javax.faces.context.FacesContext;
  66.  
  67.  
  68. @ManagedBean
  69. public class MessageManagedBean {
  70. private String message;
  71.  
  72.  
  73. public MessageManagedBean(String type) {
  74. if(type=="negativ") {
  75. outPutGrowlNEG();
  76. }
  77. if(type == "positiv") {
  78. outPutGrowlPOS();
  79. }
  80. if(type == "wrong") {
  81. System.out.println("Wrong Growl: " + type);
  82. outPutGrowlWrong();
  83. }
  84. }
  85.  
  86. public String getMessage() {
  87. return message;
  88. }
  89.  
  90. public void setMessage(String message) {
  91. this.message = message;
  92. }
  93.  
  94. public void outPutGrowlNEG() {
  95. FacesContext context = FacesContext.getCurrentInstance();
  96.  
  97. context.addMessage(null, new FacesMessage("Erfolgreich", "Die Bewertung wurde hinzugefügt..."));
  98. context.addMessage(null, new FacesMessage("Bewertung:", "Negativ"));
  99.  
  100. }
  101.  
  102. public void outPutGrowlPOS() {
  103. FacesContext context = FacesContext.getCurrentInstance();
  104.  
  105. context.addMessage(null, new FacesMessage("Erfolgreich", "Die Bewertung wurde hinzugefügt..."));
  106. context.addMessage(null, new FacesMessage("Bewertung:", "Positiv"));
  107. }
  108.  
  109. public void outPutGrowlWrong() {
  110. FacesContext context = FacesContext.getCurrentInstance();
  111. System.out.println("outPutGrowlWrong");
  112. context.addMessage(null, new FacesMessage("Passwort Inkorrekt", "Wrong Password"));
  113.  
  114. }
  115.  
  116. }
  117.  
  118. else if (lit.getName().equals(kursleiter.getName()) && !(lit.getPasswort().equals(kursleiter.getPasswort()))){
  119. System.out.println("CHECK: Could not find a match");
  120. String type = "wrong";
  121. MessageManagedBean mmb = new MessageManagedBean(type);
  122. /*
  123. * Die Session schon da schliessen, sonst ist es unsicher
  124. */
  125. transaction.commit();
  126. session.close();
  127. sessionFactory.close();
  128. return "nok";
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement