JSF Ders09 - Form Tag Elemanları | outputScript
- <h:outputScript library="klasörAdi" name="jsDosyasi.js"/>
- WebContent/resources/klasörAdi/jsDosyasi.js
Personel.java
package test; import java.io.Serializable; import java.text.SimpleDateFormat; import java.util.Date; import javax.faces.bean.*; @ManagedBean @SessionScoped public class Personel implements Serializable { private static final long serialVersionUID = 1L; private String ad; private String sifre; public void setAd(String ad) { this.ad = ad; } public String getAd() { return ad; } public String getSifre() { return sifre; } public void setSifre(String sifre) { this.sifre = sifre; } public String gonder() { return ("personel-bilgi?faces-redirect=true"); } }
index.xhtml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>index.xhtml</title> <h:outputScript library="js" name="1.js" /> <script type="text/javascript"> window.onload=karsila; </script> </h:head> <h:body> <h:form> Adinizi girin.<br /> <h:inputText value="#{personel.ad}" /><br/><br/> Sifrenizi girin.<br /> <h:inputSecret value="#{personel.sifre}" /><br/><br/> <h:commandButton value="giris yap" type="submit" action="#{personel.gonder}" /> <h:commandButton value="temizle" type="reset"/> </h:form> </h:body> </html>
personel-bilgi.xhtml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>personel-bilgi.xhtml</title> </h:head> <h:body> <h:outputFormat value="Hosgeldin {0} !" > <f:param value="#{personel.ad}" /> </h:outputFormat> <br/><br/> <table> <tr><th>PERSONEL BİLGİLERİ</th></tr> <tr><td>Ad</td><td><h:outputText value="#{personel.ad}"/></td></tr> <tr><td>Sifre</td><td><h:outputText value="#{personel.sifre}"/></td></tr> </table> </h:body> </html>
function karsila(){ alert("Merhaba !"); }
Yorumlar
Yorum Gönder