JSF Ders17 - Form Tag Elemanları | selectOneMenu
<h:selectOneMenu value="#{sinifIsmi.secilen}"> <f:selectItems value="#{sinifIsmi.secenekler}"/> </h:selectOneMenu> |
<h:selectOneMenu value="#{sinifIsmi.secilen}"> <f:selectItem itemValue="secenek1" itemLabel="secenek1"/> <f:selectItem itemValue="secenek2" itemLabel="secenek2"/> </h:selectOneMenu> |
package test; import java.io.Serializable; import java.util.Arrays; import javax.faces.bean.*; @ManagedBean @SessionScoped public class Personel implements Serializable { private static final long serialVersionUID = 1L;
// diğer üye elemanlar
private String evcilHayvan; private String evcilCinsiyet; private String[] evcilCinsiyetler={"erkek","disi"}; // diğer üye metotlar
public String getEvcilHayvan() { return evcilHayvan; } public void setEvcilHayvan(String evcilHayvan) { this.evcilHayvan = evcilHayvan; } public String getEvcilCinsiyet() { return evcilCinsiyet; } public void setEvcilCinsiyet(String evcilCinsiyet) { this.evcilCinsiyet = evcilCinsiyet; } public String[] getEvcilCinsiyetler() { return evcilCinsiyetler; } public void setEvcilCinsiyetler(String[] evcilCinsiyetler) { this.evcilCinsiyetler = evcilCinsiyetler; } 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://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" > <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>index.xhtml</title> </h:head> <h:body>
<h:form>
<!-- diğer form elemanları -->
Evcil Hayvan <h:selectOneMenu value="#{personel.evcilHayvan}"> <f:selectItem itemLabel="--Evcil Seç--"/> <f:selectItem itemValue="kopek" itemLabel="kopek"/> <f:selectItem itemValue="kedi" itemLabel="kedi"/> <f:selectItem itemValue="kus" itemLabel="kus"/> </h:selectOneMenu> Evcil Hayvan Cinsiyeti <h:selectOneMenu value="#{personel.evcilCinsiyet}"> <f:selectItem itemLabel="--Evcil Cinsiyet Seç--"/> <f:selectItems value="#{personel.evcilCinsiyetler}"/> </h:selectOneMenu> <br/><br/> <h:commandButton value="giris yap" type="submit" action="#{personel.gonder}" /> <h:commandButton value="temizle" type="reset"/><br/><br/> </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://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" > <h:head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>personel-bilgi.xhtml</title> <h:outputStylesheet library="css" name="1.css"/> </h:head> <h:body> <h:outputFormat value="Hosgeldin {0} !" > <f:param value="#{personel.ad}" /> </h:outputFormat> <br/><br/> <p class="baslik">PERSONEL BİLGİLERİ</p> <table> <tr><th>Özellik</th><th>Değer</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> <tr><td>Ev</td><td><h:outputText value="#{personel.ev}"/></td></tr> <tr><td>Araba</td><td><h:outputText value="#{personel.araba}"/></td></tr> <tr><td>Calistigi Yillar</td><td><h:outputText value="#{personel.yillartoString}" /></td></tr> <tr><td>Ugurlu Sayilar</td><td> <h:outputText value="#{personel.sayilartoString}" /></td></tr> <tr><td>Cinsiyet</td><td> <h:outputText value="#{personel.cinsiyetim}" /></td></tr> <tr><td>Yas Araligi</td><td> <h:outputText value="#{personel.yasAraligim}" /></td></tr> <tr><td>Randevu (GUN/AY)</td><td><h:outputText value="#{personel.randevuGunum}" />/<h:outputText value="#{personel.randevuAyim}" /></td></tr> <tr><td>Sehirler</td><td> <h:outputText value="#{personel.sehirlerimtoString}" /></td></tr> <tr><td>Renkler</td><td> <h:outputText value="#{personel.renklerimtoString}" /></td></tr> <tr><td>EvcilHayvan/Cinsiyeti</td><td><h:outputText value="#{personel.evcilHayvan}" />/<h:outputText value="#{personel.evcilCinsiyet}" /></td></tr> </table> </h:body> </html>
Yorumlar
Yorum Gönder