JSF Ders07 - Form Tag Elemanları | outputFormat
<h:outputFormat value="yazilacakMesaj {0},{1}> <f:param value="parametre1"/> <f:param value="parametre2"/> </h:outputFormat> |
outputFormat ögesi parametreli çıktı üretebilmek için kullanılır. Yukarıdaki kodun çıktısı şu şekilde olacaktır.
- yazilacakMesaj parametre1,parametre2
Personel.java
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; 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: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: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>#{personel.ad}</td></tr> <tr><td>Sifre</td><td>#{personel.sifre}</td></tr> </table> </h:body> </html>
Yorumlar
Yorum Gönder