JSF Ders12 - Form Tag Elemanları | selectBooleanCheckbox


  • <h:selectBooleanCheckbox value="#{sinifIsmi.degiskenIsmi}"/>

JSF'de tek bir checkbox yukarıdaki şekilde oluşturulur.Burada dikkat edilmesi gereken husus checkbox değişkeninin boolean tipinde olmasıdır.


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;
 private boolean ev;
 private boolean araba;
 
 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 boolean isEv() {
  return ev;
 }

 public void setEv(boolean ev) {
  this.ev = ev;
 }

 public boolean isAraba() {
  return araba;
 }

 public void setAraba(boolean araba) {
  this.araba = araba;
 }

 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/>
  Sifrenizi girin.<br />
  <h:inputSecret value="#{personel.sifre}" /><br/><br/>
  Ev<h:selectBooleanCheckbox value="#{personel.ev}" />
  Araba<h:selectBooleanCheckbox value="#{personel.araba}" /><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: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:outputStylesheet library="css" name="1.css"/>
</h:head>
<h:body>
<h:outputStylesheet name="css/1.css"/>
<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>
 </table>
 

</h:body>
</html>


JSF selectBooleanCheckbox

JSF selectBooleanCheckbox

Yorumlar

Bu blogdaki popüler yayınlar

JSP Ders04 - JSP Direktifleri

SQL Ders27 - INSERT INTO

Java Mini Proje 005 - Dik Üçgenin Hipotenüsünü Bulma