PHP Faces Programlanabilir Şablonlar

0

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

Programlanabilir şablonlar @htmlpattern lerdir yapısal geliştirme çalışmaları sürmektedir.
Örnek kullanıldığı her yerde1 ile 12 arasındaki sayıları gösteren pattern
Sablon.ptrn dosyası

<faces>
<@htmlpattern name="yaz" useprefix="my">
<c:for var="$i" begin="1" to="12" step="1">
<div style="color:red;font-weight:bold;" > #{$i}  </div>
</c:for>
</@htmlpattern>
</faces>

View dosyası

<faces>
<@face file="sablon.ptrn"/>
<my:yaz/>
</faces>

Örneğin kullanıcı girişi için kullandığımız bir formumuz olsun formumuzu kullmak istediğimiz dosyaya include ederiz ve ismi ile etiketleriz

Sablon.ptrn dosyası

<faces>
<@import taglib="phpf.ui.*" prefix="f"/>
<@import taglib="phpf.core" prefix="c" type="static"/>
<@htmlpattern name="login" useprefix="my">
<f:form id="loginform">
<table>
    <tr>
        <td>User Name</td>
        <td><f:textbox id="name"/></td>
    </tr>
      <tr>
        <td>Password</td>
        <td><f:textbox id="pass"/></td>
    </tr>
    </tr>
      <tr>
        <td>Password</td>
        <td><f:button id="send" forname="loginform" text="Login" onclick="actionevent"/></td>
    </tr>
</table>
</f:form>
</@htmlpattern>
</faces>

View dosyası

<faces>
<@face file="sablon.ptrn"/>
<my:login/>
</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)

Bileşen Niteliklerine Controllerdan Erişim Örnek Style Kullanımı

0

Tarih : 11-09-2009 | Yazan : Hüseyin Bora | Kategori : PHP Faces

Niteliklere erişiken nesne adı -> nitelik adı şeklindendir. örneğim bir textbox birde button bileşenimiz olsun buttona tıklandığında textbox un rengini değiştirelim.  faces view tanımlaması aşağıdaki gibidir.

<faces>
<@import taglib="phpf.ui.*" prefix="face"/>
<face:textbox name ="yazi"  text ="Merhaba"/>
<face:textbox name ="button"  text ="Rengi Değiştir"/>
</faces>
class Controller extends Facete{
function Controller(){
parent::FacesController();
$this->render("view.html");
}
function buttonClicked($evt){
$this->yazi->setProperty("style", "background:blue");
}
}

Örneğimizde textbox bileşenin style niteliğine background:blue değerini artardık ve rengini değiştirmiş olduk.

Bir niteliği değiştirmek istediğinizde

$this->bilesenadi->nitelik=”deger”;

Ya da

$this->yazi->setProperty(”nitelik”, “değer”);

İki kullanımda gecerlidir.

Şimdi örneğimizi biraz daha geliştirelim bir combobox bileşeninde renkler olsun ve seçilen rengi ajax kullanarak textbox nesnesine uygulayalım.

Örneğimiz için view aşağıdaki şekildedir.

<faces>
<@import prefix="face" taglib="phpf.ui.*"/>
<face:textbox name ="textbox"  text ="Merhaba"/>
Rengi değiştir
<face:combobox name="colors"
bind="array(Aqua,Blue,AliceBlue,Beige,Black,Brown ,Navy,Pink,Red,Orange,Yellow ,White,Green)"
onchange="ajaxevent">
</face:combobox>
</faces>
import("phpf.controllers.facete");
class Style extends Facete
{
function Style()
{
parent::Facete();
$this->render("view.phpf");
}

protected function colorsChanged($evt)
{
$color = $this->colors->getSelected();
$this->textbox->setProperty("style","background:$color");
$this->AjaxResponse();
}
}

İşte Uygulamamızın Çalışır hali.

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)

İf etiketi

0

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

if etiketi

Karşılaştırma yapmak için kullanılır test niteliğine karşılaştırma ifadesi yerleştirilir.

Örnek İf

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

İf için başkabir örnek

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:if test="#{$i>0  AND $i<10}">
<c:out value="sayı  10 ile  1 arasinda"/>
</c:if>
</faces>
 

İf için başkabir örnek

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:if test="#{$name!='bora'}">
<strong>
<c:out value="Bu benim adım değil !"/>
</strong>
</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)

PHP Faces FDL Core kütüphanesi

0

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

Core statik bir etiket kütüphanesidir. içerisinde temel işlem etiketleri bulunur. bunlar

  • out
  • if
  • else
  • elseif
  • for
  • foreach

Core kütüphanesini aşağıdaki gibi view dosyasına dahil edilir

<@import prefix="c" taglib="phpf.core" type="static"/>

Out etiketi

Çıktı için kullanılır. çıktıya gönderilecek veri  bu etiketin value niteliği ile belirtilir

Örnek Out

<faces>
<@import prefix="c" taglib="phpf.core" type="static"/>
<c:out value="Merhaba dünya"/>
<c:out value="#{birdeğişken}"/>
</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)