JSF Ders05 - Form Tag Elemanları | outputText
- <h:outputText value="#{sinifIsmi.degisken}"/>
Sayfa yüklendiğinde "sinifIsmi.degisken" değeri getter metoduyla çağrılarak değişkenin değeri gösterilir.
Uzun olarak <h:outputText value="#{sinifIsmi.degisken}"/> yazmak yerine direkt olarak şu ifade de kullanılabilir.
- #{sinifIsmi.degisken}
package test; import java.io.Serializable; import javax.faces.bean.*; @ManagedBean @SessionScoped public class Personel implements Serializable { private static final long serialVersionUID = 1L; private String ad; public void setAd(String ad) { this.ad = ad; } public String getAd() { return ad; } 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:head> <h:body> <h:form> Adinizi girin.<br /> <h:inputText value="#{personel.ad}" /><br/><br/> <h:commandButton value="giris yap" action="#{personel.gonder}" /> </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:h="http://xmlns.jcp.org/jsf/html"> <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>personel-bilgi.xhtml</title> </h:head> <h:body> <table> <tr><th>PERSONEL BİLGİLERİ</th></tr> <tr><td>Ad</td><td><h:outputText value="#{personel.ad}" /></td></tr> </table> </h:body> </html>
Yorumlar
Yorum Gönder