PHP Faces UI Dojo Widget örnekleri

0

Tarih : 02-11-2009 | Yazan : Hüseyin Bora | Kategori : FDL, FDL Core, PHP, PHP Faces

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Foreach etiketi

0

Tarih : 09-09-2009 | Yazan : Hüseyin Bora | Kategori : FDL, FDL Core, PHP Faces

For etiketine benzer bir şekilde çalışır diziler ve nesneler üzerinde etkilidir. var ve item isimlerinde iki niteliği vardır

var: iterasyon yapılacak nesne ya da dizi

item : işlem sırasındaki gecerli nesne

Örnek foreach

<?php class Person {

public $id;

public $name;

public $phones =array();
}
?>

Yukarıdaki sınıftan oluşturulan bir diziyi dolaşan foreach örneği

örnekteki $this.list  Person sınıfı dizisidir.

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:foreach var="$this.list" item="$item">
  <br/>
   Name :<c:out value="#{$item.name}"/>
   Id :<c:out value="#{$item.id}"/>
  </c:foreach>
<faces>

Örnek iç içe foreach etiketleri

<faces>
 <@import prefix="c" taglib="phpf.core" type="static"/>
 <c:foreach var="$this.list" item="$item">
      <br/>
      Name :<c:out value="#{$item.name}"/>
      Id :<c:out value="#{$item.id}"/>
       <c:foreach var="$item.phones" item="$phone">
          Phone :<c:out value="#{$phone}"/>
   </c:foreach>
 </c:foreach>
<faces>
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

For etiketi

0

Tarih : 09-09-2009 | Yazan : Hüseyin Bora | Kategori : FDL, FDL Core, PHP Faces

for etiketi döngü oluşturmak için kullanılır. dört niteliği bulunmaktadır.

  • var : değişken
  • begin : başlama değeri bir tam sayı
  • to : bitiş değeri bir tam sayı
  • step : artış miktarı

 var ile belirten değişkeni begin ile belirtilen başlangıç değerinden başlayarak to ile belirtilen miktara ulaşıncaya kadar step ile belirtilen miktar kadar artırır.

Örnek 1 den 10 kadar olan sayıları göster.

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:for var="$i" begin="1" to="10" step="1">
<c:out value="#{$i}"/>
</c:for>
</faces>

Çıktısı şöyle olur 1,2,3,4,5,6,7,9,10

Örnek ikişer artış çift sayılar

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:for var="$i" begin="0" to="10" step="2">
<c:out value="#{$i}"/>
</c:for>
</faces>

Çıktısı şöyle olur 0,2,4,6,8,10

Örnek geriye doğru for

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:for var="$i" begin="10" to="0" step="1">
<c:out value="#{$i}"/>,
</c:for>
</faces>

Çıktısı şöyle olur 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0

Örnek iç içe for kullanımı

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:for var="$i" begin="0" to="10" step="1">
<br>
<c:out value="i = #{$i}"/>
<c:for var="$j" begin="$i" to="10" step="2">
<c:out value="j = #{$j}"/>,
</c:for>
</c:for>
</faces>

Çıktısı şöyle olur

i = 0, j = 0, j = 2, j = 4, j = 6, j = 8, j = 10
i = 1, j = 1, j = 3, j = 5, j = 7, j = 9
i = 2, j = 2, j = 4, j = 6, j = 8, j = 10
i = 3, j = 3, j = 5, j = 7, j = 9
i = 4, j = 4, j = 6, j = 8, j = 10
i = 5, j = 5, j = 7, j = 9
i = 6, j = 6, j = 8, j = 10
i = 7, j = 7, j = 9
i = 8, j = 8, j = 10
i = 9, j = 9
i = 10, j = 10

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Elseif etiketi

0

Tarih : 09-09-2009 | Yazan : Hüseyin Bora | Kategori : FDL, FDL Core, PHP Faces

elseif etiketi if etiketi ile birlikte kullanılır. if ile kullanılan ifadenin yanlış olması durumunda elseif etiketinin doğrulu karşılaştırılır.

Örnek elseif

<@import prefix="c" taglib="phpf.core" type="static"/>
<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:if test="#{$name=='bora'}">
<c:out value="#{$name}"/>
<c:elseif test="#{$name=='huseyin'}">
<c:out value="isim huseyin"/>
</c:elseif>
</c:if>
</faces>

Örnek if elseif else

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:if test="#{$name=='bora'}">
<c:out value="isim bora"/>
<c:elseif test="#{$name=='huseyin}">
<c:out value="isim huseyin"/>
</c:elseif>
<c:else>
<c:out value="tanımsız bir isim"/>
</c:else>
</c:if>
</faces>
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Else etiketi

0

Tarih : 09-09-2009 | Yazan : Hüseyin Bora | Kategori : FDL, FDL Core, PHP Faces

Else etiketi if etiketi ile birlikte kullanılır. if ile kullanılan ifaden yanlış olması durumunda geçerlidir.

Örnek else

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:if test="$name=='bora'">
<c:out value="#{$name}"/>
<c:else>
<c:out value="Başka bir isim  #{$name}"/>
</c:else>
</c:if>
<faces>

Çift ve tek sayıları ayırt eden bir örnek

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:for var="$i" begin="1" to="12" step="1">
<c:if test="($i%2)==1">
<c:out value="#{$i}"/> tek sayı<br />
<c:else>
<c:out value="#{$i}"/> çift sayı<br />
</c:else>
</c:if>
</c:for>
<faces>
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)