Advertisement
Guest User

Untitled

a guest
Dec 5th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.19 KB | None | 0 0
  1. package lab3;
  2.  
  3. import javax.faces.application.FacesMessage;
  4. import javax.faces.component.UIComponent;
  5. import javax.faces.component.html.HtmlInputSecret;
  6. import javax.faces.component.html.HtmlInputText;
  7. import javax.faces.context.FacesContext;
  8. import javax.faces.validator.Validator;
  9. import javax.faces.validator.ValidatorException;
  10.  
  11. import org.apache.commons.lang3.StringUtils;
  12.  
  13. public class AlphanumericValidator implements Validator {
  14. @Override
  15. public void validate(FacesContext context, UIComponent uiComp, Object value) throws ValidatorException {
  16. org.apache.commons.validator.EmailValidator emailValidator = org.apache.commons.validator.EmailValidator.getInstance();
  17.  
  18.  
  19. if(!StringUtils.isAlphaSpace((String) value))
  20. {
  21. HtmlInputSecret htmlInputSecret = (HtmlInputSecret) uiComp;
  22. FacesMessage facesMessage = new FacesMessage(htmlInputSecret.getLabel()
  23. + ": dozwolone tylko litery");
  24.  
  25. throw new ValidatorException(facesMessage);
  26. }
  27. }
  28. }
  29.  
  30. package lab3;
  31.  
  32. import com.j256.ormlite.field.DatabaseField;
  33. import com.j256.ormlite.table.DatabaseTable;
  34.  
  35. @DatabaseTable(tableName="IMIENINY")
  36. public class AM_Imieniny {
  37. @DatabaseField(generatedId = true)
  38. private int id;
  39. @DatabaseField(columnName = "IMIE")
  40. private String imie;
  41. @DatabaseField(columnName = "MIESIAC")
  42. private int miesiac;
  43. @DatabaseField(columnName = "DZIEN")
  44. private int dzien;
  45.  
  46. public AM_Imieniny() {
  47. }
  48.  
  49. public AM_Imieniny(String imie, int miesiac, int dzien) {
  50. super();
  51. this.imie = imie;
  52. this.miesiac = miesiac;
  53. this.dzien = dzien;
  54. }
  55.  
  56.  
  57. public int getId() {
  58. return id;
  59. }
  60.  
  61. public void setId(int id) {
  62. this.id = id;
  63. }
  64.  
  65. public String getImie() {
  66. return imie;
  67. }
  68.  
  69. public void setImie(String imie) {
  70. this.imie = imie;
  71. }
  72.  
  73. public int getMiesiac() {
  74. return miesiac;
  75. }
  76.  
  77. public void setMiesiac(int miesiac) {
  78. this.miesiac = miesiac;
  79. }
  80.  
  81. public int getDzien() {
  82. return dzien;
  83. }
  84.  
  85. public void setDzien(int dzien) {
  86. this.dzien = dzien;
  87. }
  88.  
  89. @Override
  90. public String toString() {
  91. return "AM_Imieniny [id=" + id + ", imie=" + imie + ", miesiac=" + miesiac + ", dzien=" + dzien + "]";
  92. }
  93. }
  94.  
  95. package lab3;
  96.  
  97. import java.io.IOException;
  98. import java.io.PrintWriter;
  99. import java.sql.SQLException;
  100. import java.util.ArrayList;
  101. import java.util.Arrays;
  102. import java.util.List;
  103.  
  104. import javax.servlet.ServletException;
  105. import javax.servlet.annotation.WebServlet;
  106. import javax.servlet.http.HttpServlet;
  107. import javax.servlet.http.HttpServletRequest;
  108. import javax.servlet.http.HttpServletResponse;
  109.  
  110. import org.sqlite.SQLiteException;
  111.  
  112. import com.j256.ormlite.dao.Dao;
  113. import com.j256.ormlite.dao.DaoManager;
  114. import com.j256.ormlite.dao.GenericRawResults;
  115. import com.j256.ormlite.jdbc.JdbcConnectionSource;
  116. import com.j256.ormlite.stmt.RawResultsImpl;
  117. import com.j256.ormlite.support.ConnectionSource;
  118. import com.j256.ormlite.table.TableUtils;
  119.  
  120. /**
  121. * Servlet implementation class OrmApp
  122. */
  123. @WebServlet("/Imieniny")
  124. public class AM_ImieninyApp extends HttpServlet {
  125. private static final long serialVersionUID = 1L;
  126.  
  127. String databaseUrl = "jdbc:sqlite:imieniny.sqlite";
  128.  
  129. public AM_ImieninyApp() {
  130. super();
  131. }
  132.  
  133. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  134. response.setContentType("text/plain; charset=utf-8");
  135. response.setCharacterEncoding("utf-8");
  136.  
  137. PrintWriter out = response.getWriter();
  138.  
  139. // try {
  140.  
  141. String imie = request.getParameter("imie");
  142.  
  143. if(imie == null || imie.equals(""))
  144. {
  145. List<String> imiona = getWszystkieImiona();
  146.  
  147. for(String x : imiona)
  148. {
  149. out.println(x);
  150. }
  151. }
  152. else
  153. {
  154. List<AM_Imieniny> lista = getImieniny(imie);
  155.  
  156. if(lista == null)
  157. {
  158. out.println("Brak imienin dla imienia " + imie);
  159. return;
  160. }
  161. for(AM_Imieniny x : lista)
  162. {
  163. out.println(x.getImie() + ", " + x.getDzien() + ", " + x.getMiesiac());
  164. }
  165. }
  166.  
  167. // List<Ksiazka> listaKsiazek = ksiazkaDao.queryForAll();
  168. // out.println("ksiazek jest " + listaKsiazek.size());
  169.  
  170. // connectionSource.close();
  171. // } catch (SQLException e) {
  172. // e.printStackTrace();
  173. // }
  174. }
  175.  
  176. private List<String> getWszystkieImiona() {
  177. try {
  178. ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl);
  179. Dao<AM_Imieniny, Integer> imieninyDao = DaoManager.createDao(connectionSource, AM_Imieniny.class);
  180. GenericRawResults<String[]> rawResults = imieninyDao.queryRaw("SELECT imie FROM IMIENINY");
  181.  
  182. List<String[]> wynik = rawResults.getResults();
  183. List<String> lista = new ArrayList<>();
  184.  
  185. for(String[] x : wynik)
  186. {
  187. lista.add(x[0]);
  188. //out.println(Arrays.toString(x));
  189. }
  190.  
  191. return lista;
  192. } catch (SQLException e) {
  193. e.printStackTrace();
  194. }
  195. return null;
  196. }
  197.  
  198. private List<AM_Imieniny> getImieniny(String imie)
  199. {
  200. try {
  201. ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl);
  202. Dao<AM_Imieniny, Integer> imieninyDao = DaoManager.createDao(connectionSource, AM_Imieniny.class);
  203. GenericRawResults<String[]> rawResults = imieninyDao.queryRaw("SELECT * FROM IMIENINY");
  204.  
  205. List<String[]> wynik = rawResults.getResults();
  206. List<AM_Imieniny> lista = new ArrayList<>();
  207.  
  208. for(String[] x : wynik)
  209. {
  210. if(x[1].startsWith(imie))
  211. lista.add(new AM_Imieniny(x[1], Integer.parseInt(x[2]), Integer.parseInt(x[3])));
  212. //out.println(Arrays.toString(x));
  213. }
  214.  
  215. return lista;
  216. } catch (SQLException e) {
  217. e.printStackTrace();
  218. }
  219. return null;
  220. }
  221.  
  222. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  223. doGet(request, response);
  224. }
  225.  
  226. }
  227. package lab3;
  228.  
  229. import javax.faces.application.FacesMessage;
  230. import javax.faces.component.UIComponent;
  231. import javax.faces.component.html.HtmlCommandButton;
  232. import javax.faces.component.html.HtmlInputSecret;
  233. import javax.faces.component.html.HtmlSelectBooleanCheckbox;
  234. import javax.faces.context.FacesContext;
  235. import javax.faces.event.ValueChangeEvent;
  236. import javax.faces.validator.ValidatorException;
  237.  
  238. import org.apache.commons.lang3.StringUtils;
  239.  
  240. public class ImieninyBean {
  241. private String username;
  242. private String password;
  243.  
  244. private HtmlCommandButton submitButton;
  245. // private HtmlSelectBooleanCheckbox selectBooleanCheckbox1;
  246.  
  247. public String getUsername() {
  248. return username;
  249. }
  250. public void setUsername(String username) {
  251. this.username = username;
  252. }
  253. public String getPassword() {
  254. return password;
  255. }
  256. public void setPassword(String password) {
  257. this.password = password;
  258. }
  259.  
  260. public String register() {
  261.  
  262. return (username.equals("user@user.com") && password.equals("user")) ? "success" : "failure";
  263. }
  264.  
  265.  
  266. public String login() {
  267.  
  268. return (username.equals("user@user.com") && password.equals("user")) ? "success" : "failure";
  269. }
  270.  
  271. public HtmlCommandButton getSubmitButton() {
  272. return submitButton;
  273. }
  274.  
  275. public void setSubmitButton(HtmlCommandButton submitButton) {
  276. this.submitButton = submitButton;
  277. }
  278.  
  279. // public HtmlSelectBooleanCheckbox getSelectBooleanCheckbox1() {
  280. // return selectBooleanCheckbox1;
  281. // }
  282.  
  283. // public void setSelectBooleanCheckbox1(HtmlSelectBooleanCheckbox selectBooleanCheckbox1) {
  284. // this.selectBooleanCheckbox1 = selectBooleanCheckbox1;
  285. // }
  286. //
  287. // public void checkbox1Changed(ValueChangeEvent valueChangedEvent)
  288. // {
  289. // if(selectBooleanCheckbox1.isSelected())
  290. // {
  291. // submitButton.setDisabled(false);
  292. // } else {
  293. // submitButton.setDisabled(true);
  294. // }
  295. //
  296. // FacesContext context = FacesContext.getCurrentInstance();
  297. // context.renderResponse();
  298. // }
  299.  
  300. public void validateAlpha(FacesContext context, UIComponent uiComp, Object value)
  301. throws ValidatorException
  302. {
  303. if(!StringUtils.isAlphaSpace((String) value))
  304. {
  305. HtmlInputSecret htmlInputSecret = (HtmlInputSecret) uiComp;
  306. FacesMessage facesMessage = new FacesMessage(htmlInputSecret.getLabel()
  307. + ": dozwolone tylko litery");
  308.  
  309. throw new ValidatorException(facesMessage);
  310. }
  311. }
  312. }
  313. package lab3;
  314.  
  315. import java.io.IOException;
  316. import java.sql.SQLException;
  317. import java.util.List;
  318.  
  319. import javax.faces.application.FacesMessage;
  320. import javax.faces.component.UIComponent;
  321. import javax.faces.component.html.HtmlCommandButton;
  322. import javax.faces.component.html.HtmlInputSecret;
  323. import javax.faces.component.html.HtmlInputText;
  324. import javax.faces.component.html.HtmlSelectBooleanCheckbox;
  325. import javax.faces.context.FacesContext;
  326. import javax.faces.event.ValueChangeEvent;
  327. import javax.faces.validator.ValidatorException;
  328.  
  329. import org.apache.commons.lang3.StringUtils;
  330.  
  331. import com.j256.ormlite.dao.Dao;
  332. import com.j256.ormlite.dao.DaoManager;
  333. import com.j256.ormlite.dao.GenericRawResults;
  334. import com.j256.ormlite.jdbc.JdbcConnectionSource;
  335. import com.j256.ormlite.support.ConnectionSource;
  336. import com.j256.ormlite.table.TableUtils;
  337.  
  338. public class Login {
  339. private String username;
  340. private String password;
  341.  
  342. private HtmlCommandButton submitButton;
  343. // private HtmlSelectBooleanCheckbox selectBooleanCheckbox1;
  344.  
  345.  
  346. private static final long serialVersionUID = 1L;
  347.  
  348. static String databaseUrl = "jdbc:sqlite:ludzie.sqlite";
  349. public String getUsername() {
  350. return username;
  351. }
  352. public void setUsername(String username) {
  353. this.username = username;
  354. }
  355. public String getPassword() {
  356. return password;
  357. }
  358. public void setPassword(String password) {
  359. this.password = password;
  360. }
  361. //
  362. // public String register() {
  363. //
  364. // return (username.equals("user@user.com") && password.equals("user")) ? "success" : "failure";
  365. // }
  366.  
  367. public class Db
  368. {
  369. boolean login(String name, String password)
  370. {
  371.  
  372. System.out.println("name = " + name ==null ? "null" : name);
  373. System.out.println("password = " + password ==null ? "null" : password);
  374.  
  375. try {
  376. ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl);
  377. Dao<User, Integer> userDao = DaoManager.createDao(connectionSource, User.class);
  378. TableUtils.createTableIfNotExists(connectionSource, User.class);
  379.  
  380. User user = new User(name, password);
  381.  
  382. GenericRawResults<String[]> rawResults = userDao.queryRaw("SELECT * FROM ludzie");
  383.  
  384. List<String[]> wynik = rawResults.getResults();
  385.  
  386.  
  387. for(String[] x : wynik)
  388. {
  389. if(x[1].equals(name) && x[2].equals(password))
  390. {
  391. return true;
  392. }
  393. }
  394.  
  395. try {
  396. connectionSource.close();
  397. } catch (IOException e) {
  398. }
  399. } catch (SQLException e) {
  400. e.printStackTrace();
  401. return false;
  402. }
  403. return false;
  404. }
  405. }
  406.  
  407. public String login() {
  408. Db db = new Db();
  409.  
  410. System.out.println("name = " + username ==null ? "null" : username);
  411. System.out.println("password = " + password ==null ? "null" : password);
  412.  
  413. return db.login(username, password) ? "success" : "failure";
  414. }
  415.  
  416. public HtmlCommandButton getSubmitButton() {
  417. return submitButton;
  418. }
  419.  
  420. public void setSubmitButton(HtmlCommandButton submitButton) {
  421. this.submitButton = submitButton;
  422. }
  423.  
  424. // public HtmlSelectBooleanCheckbox getSelectBooleanCheckbox1() {
  425. // return selectBooleanCheckbox1;
  426. // }
  427.  
  428. // public void setSelectBooleanCheckbox1(HtmlSelectBooleanCheckbox selectBooleanCheckbox1) {
  429. // this.selectBooleanCheckbox1 = selectBooleanCheckbox1;
  430. // }
  431. //
  432. // public void checkbox1Changed(ValueChangeEvent valueChangedEvent)
  433. // {
  434. // if(selectBooleanCheckbox1.isSelected())
  435. // {
  436. // submitButton.setDisabled(false);
  437. // } else {
  438. // submitButton.setDisabled(true);
  439. // }
  440. //
  441. // FacesContext context = FacesContext.getCurrentInstance();
  442. // context.renderResponse();
  443. // }
  444.  
  445. public void validateEmail(FacesContext context, UIComponent uiComp, Object value)
  446. throws ValidatorException
  447. {
  448.  
  449. org.apache.commons.validator.EmailValidator emailValidator = org.apache.commons.validator.EmailValidator.getInstance();
  450.  
  451.  
  452. if(!emailValidator.isValid((String) value))
  453. {
  454. HtmlInputText htmlInputSecret = (HtmlInputText) uiComp;
  455. FacesMessage facesMessage = new FacesMessage(htmlInputSecret.getLabel()
  456. + ": Email bledny");
  457.  
  458. throw new ValidatorException(facesMessage);
  459. }
  460. }
  461. }
  462.  
  463. package lab3;
  464.  
  465. import java.io.IOException;
  466. import java.sql.SQLException;
  467.  
  468. import javax.faces.application.FacesMessage;
  469. import javax.faces.component.UIComponent;
  470. import javax.faces.component.html.HtmlCommandButton;
  471. import javax.faces.component.html.HtmlInputSecret;
  472. import javax.faces.component.html.HtmlInputText;
  473. import javax.faces.component.html.HtmlSelectBooleanCheckbox;
  474. import javax.faces.context.FacesContext;
  475. import javax.faces.event.ValueChangeEvent;
  476. import javax.faces.validator.ValidatorException;
  477.  
  478. import org.apache.commons.lang3.StringUtils;
  479.  
  480. import com.j256.ormlite.dao.Dao;
  481. import com.j256.ormlite.dao.DaoManager;
  482. import com.j256.ormlite.jdbc.JdbcConnectionSource;
  483. import com.j256.ormlite.support.ConnectionSource;
  484. import com.j256.ormlite.table.TableUtils;
  485.  
  486. public class Register {
  487. private String username;
  488. private String password;
  489.  
  490. private static final long serialVersionUID = 1L;
  491.  
  492. static String databaseUrl = "jdbc:sqlite:ludzie.sqlite";
  493.  
  494. static
  495. {
  496. // workaround aby dropowac tylko raz
  497. try {
  498. ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl);
  499. Dao<User, Integer> userDao = DaoManager.createDao(connectionSource, User.class);
  500. TableUtils.dropTable(connectionSource, User.class, true);
  501. TableUtils.createTableIfNotExists(connectionSource, User.class);
  502. } catch (SQLException e) {
  503. e.printStackTrace();
  504. }
  505. }
  506.  
  507. private HtmlCommandButton submitButton;
  508. // private HtmlSelectBooleanCheckbox selectBooleanCheckbox1;
  509.  
  510. public String getUsername() {
  511. return username;
  512. }
  513. public void setUsername(String username) {
  514. this.username = username;
  515. }
  516. public String getPassword() {
  517. return password;
  518. }
  519. public void setPassword(String password) {
  520. this.password = password;
  521. }
  522.  
  523. // public String register() {
  524. //
  525. // return (username.equals("user@user.com") && password.equals("user")) ? "success" : "failure";
  526. // }
  527.  
  528. public class Db
  529. {
  530. boolean register(String name, String password)
  531. {
  532. try {
  533. ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl);
  534. Dao<User, Integer> userDao = DaoManager.createDao(connectionSource, User.class);
  535. TableUtils.createTableIfNotExists(connectionSource, User.class);
  536.  
  537. User user = new User(name, password);
  538.  
  539. userDao.create(user);
  540.  
  541. try {
  542. connectionSource.close();
  543. } catch (IOException e) {
  544. }
  545. } catch (SQLException e) {
  546. e.printStackTrace();
  547. return false;
  548. }
  549. return true;
  550. }
  551. }
  552.  
  553. public String register() {
  554. Db db = new Db();
  555. return db.register(username, password) ? "success" : "failure";
  556. }
  557.  
  558. public HtmlCommandButton getSubmitButton() {
  559. return submitButton;
  560. }
  561.  
  562. public void setSubmitButton(HtmlCommandButton submitButton) {
  563. this.submitButton = submitButton;
  564. }
  565.  
  566. // public HtmlSelectBooleanCheckbox getSelectBooleanCheckbox1() {
  567. // return selectBooleanCheckbox1;
  568. // }
  569.  
  570. // public void setSelectBooleanCheckbox1(HtmlSelectBooleanCheckbox selectBooleanCheckbox1) {
  571. // this.selectBooleanCheckbox1 = selectBooleanCheckbox1;
  572. // }
  573. //
  574. // public void checkbox1Changed(ValueChangeEvent valueChangedEvent)
  575. // {
  576. // if(selectBooleanCheckbox1.isSelected())
  577. // {
  578. // submitButton.setDisabled(false);
  579. // } else {
  580. // submitButton.setDisabled(true);
  581. // }
  582. //
  583. // FacesContext context = FacesContext.getCurrentInstance();
  584. // context.renderResponse();
  585. // }
  586.  
  587. public void validateEmail(FacesContext context, UIComponent uiComp, Object value)
  588. throws ValidatorException
  589. {
  590.  
  591. org.apache.commons.validator.EmailValidator emailValidator = org.apache.commons.validator.EmailValidator.getInstance();
  592.  
  593.  
  594. if(!emailValidator.isValid((String) value))
  595. {
  596. HtmlInputText htmlInputSecret = (HtmlInputText) uiComp;
  597. FacesMessage facesMessage = new FacesMessage(htmlInputSecret.getLabel()
  598. + ": Email bledny");
  599.  
  600. throw new ValidatorException(facesMessage);
  601. }
  602. }
  603. }
  604. package lab3;
  605.  
  606. import com.j256.ormlite.field.DatabaseField;
  607. import com.j256.ormlite.table.DatabaseTable;
  608.  
  609. @DatabaseTable(tableName="ludzie")
  610. public class User {
  611. @DatabaseField(generatedId = true)
  612. private int id;
  613. @DatabaseField(columnName = "email")
  614. private String email;
  615. @DatabaseField(columnName = "haslo")
  616. private String haslo;
  617.  
  618. public User() {
  619. }
  620.  
  621. public User(String email, String haslo) {
  622. super();
  623. this.email = email;
  624. this.haslo = haslo;
  625. }
  626.  
  627.  
  628. public int getId() {
  629. return id;
  630. }
  631.  
  632. public void setId(int id) {
  633. this.id = id;
  634. }
  635.  
  636. public String getEmail() {
  637. return email;
  638. }
  639.  
  640. public void setEmail(String email) {
  641. this.email = email;
  642. }
  643.  
  644. public String getHaslo() {
  645. return haslo;
  646. }
  647.  
  648. public void setHaslo(String haslo) {
  649. this.haslo = haslo;
  650. }
  651.  
  652. @Override
  653. public String toString() {
  654. return "User [id=" + id + ", email=" + email + ", haslo=" + haslo + "]";
  655. }
  656.  
  657. }
  658.  
  659. //JSP
  660.  
  661. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  662. pageEncoding="utf-8"%>
  663. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  664. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  665. <!DOCTYPE html>
  666. <f:view>
  667. <html>
  668. <head>
  669. <meta charset="utf-8">
  670. <title>ERROR</title>
  671. </head>
  672. <body>
  673. <h1>Niestety, nie udało się wykonac operacji!</h1>
  674. </body>
  675. </html>
  676. </f:view>
  677.  
  678. <!DOCTYPE html>
  679. <html>
  680.  
  681. <head>
  682. <meta charset="UTF-8">
  683. <title>Sugestie Lab1</title>
  684. <script type="text/javascript">
  685. function pobierzSugestie() {
  686. tekst = document.getElementById("pole").value;
  687. if(tekst != "") {
  688. requester = new XMLHttpRequest();
  689.  
  690. requester.onreadystatechange = myHandler;
  691.  
  692. requester.open("POST", "Sugestie");
  693. requester.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  694. requester.send("query=" + tekst);
  695. }
  696. }
  697.  
  698. function myHandler() {
  699. if(requester.readyState == 4) {
  700. if(requester.status == 200) {
  701. el = document.getElementById("lista");
  702. lista = requester.responseText.split(";");
  703. odpowiedz = "";
  704.  
  705. for(i=0; i < lista.length - 1; ++i) {
  706. odpowiedz += (lista[i]+"<br/>");
  707. }
  708.  
  709. el.innerHTML = odpowiedz;
  710. }
  711.  
  712. }
  713. }
  714. </script>
  715. </head>
  716.  
  717. <body>
  718. <h4>Wpisz marke samochodu</h4>
  719. <input id="pole" type="text" onkeyup="javascript:pobierzSugestie();" />
  720.  
  721. <div id="lista"></div>
  722. </body>
  723.  
  724. </html>
  725.  
  726. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  727. pageEncoding="utf-8"%>
  728. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  729. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  730. <!DOCTYPE html>
  731. <f:view>
  732. <html>
  733. <head>
  734. <meta charset="utf-8">
  735. <title>IMIENINY!</title>
  736. </head>
  737. <body>
  738. <h:form>
  739.  
  740. <h1>ZALOGUJ</h1>
  741.  
  742.  
  743. <p>Uzytkownik: <h:inputText id="username"
  744. value="#{loginBean.username}"
  745. label="Uzytkownik"
  746. required="true"
  747. validator="#{loginBean.validateEmail}"/>
  748. <h:message for="username"/>
  749. </p>
  750.  
  751. <p>Hasło: <h:inputSecret
  752. id="password"
  753. value="#{loginBean.password}"
  754. label="Haslo"
  755. required="true">
  756. <f:validator validatorId="alphaValidator"/>
  757. </h:inputSecret>
  758. <h:message for="password"/>
  759. </p>
  760.  
  761.  
  762.  
  763. <p><h:commandButton value="Zaloguj"
  764. id="submitButton"
  765. action="#{loginBean.login}"
  766. binding="#{loginBean.submitButton}"
  767. disabled="false"/>
  768. </p>
  769. </h:form>
  770. </body>
  771. </html>
  772. </f:view>
  773.  
  774. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  775. pageEncoding="utf-8"%>
  776. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  777. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  778. <!DOCTYPE html>
  779. <f:view>
  780. <html>
  781. <head>
  782. <meta charset="utf-8">
  783. <title>OK</title>
  784. </head>
  785. <body>
  786. <p>Zostałeś zalogowany z emailem: <h:outputText value="#{loginBean.username}!"/></p>
  787. <p>Twoje haslo to: <h:outputText value="#{loginBean.password}!"/></p>
  788. <br/>
  789. </body>
  790. </html>
  791. </f:view>
  792.  
  793. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  794. pageEncoding="utf-8"%>
  795. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  796. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  797. <!DOCTYPE html>
  798. <f:view>
  799. <html>
  800. <head>
  801. <meta charset="utf-8">
  802. <title>OK</title>
  803. </head>
  804. <body>
  805. <p>Zostałeś zarejestrowany z mailem <h:outputText value="#{loginBean.username}!"/></p>
  806. <!-- <p>Twoje haslo to: <h:outputText value="#{loginBean.password}!"/></p>
  807. --><p>
  808.  
  809. </body>
  810. </html>
  811. </f:view>
  812.  
  813. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  814. pageEncoding="utf-8"%>
  815. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  816. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  817. <!DOCTYPE html>
  818. <f:view>
  819. <html>
  820. <head>
  821. <meta charset="utf-8">
  822. <title>IMIENINY!</title>
  823. </head>
  824. <body>
  825. <h:form>
  826.  
  827. <p>Uzytkownik: <h:inputText id="username"
  828. value="#{registerBean.username}"
  829. label="Uzytkownik"
  830. required="true"
  831. validator="#{registerBean.validateEmail}"/>
  832. <h:message for="username"/>
  833. </p>
  834.  
  835. <p>Hasło: <h:inputSecret
  836. id="password"
  837. value="#{registerBean.password}"
  838. label="Haslo"
  839. required="true">
  840. <f:validator validatorId="alphaValidator"/>
  841. </h:inputSecret>
  842. <h:message for="password"/>
  843. </p>
  844.  
  845. <p><h:commandButton value="Zarejestruj"
  846. id="submitButton"
  847. action="#{registerBean.register}"
  848. binding="#{registerBean.submitButton}"
  849. disabled="false"/>
  850. </p>
  851. </h:form>
  852. </body>
  853. </html>
  854. </f:view>
  855.  
  856. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  857. pageEncoding="utf-8"%>
  858. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  859. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  860. <!DOCTYPE html>
  861. <f:view>
  862. <html>
  863. <head>
  864. <meta charset="utf-8">
  865. <title>IMIENINY!</title>
  866. </head>
  867. <body>
  868. <h:form>
  869.  
  870. <h1>ZALOGOWANY</h1>
  871.  
  872.  
  873. <p>Zostałeś zarejestrowany z mailem <h:outputText value="#{loginBean.username}!"/></p>
  874. <p>Twoje haslo to: <h:outputText value="#{loginBean.password}!"/></p>
  875.  
  876. Imieniny:
  877. <br/>
  878. <input type="text" name="imie"><br>
  879.  
  880. <p><h:commandButton value="Sprawdz imieniny [jeszcze nie zaimplementowane :(]"
  881. id="submitButton"
  882. disabled="true"/>
  883. </p>
  884. </h:form>
  885. </body>
  886. </html>
  887. </f:view>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement