Doğrulama tanımlamaları view(görünün) içerisinde bileşen niteliklerine atama yapılarak sağlanır. Doğrulama sonucları event (olay) nesnesinin niteliğine göre AJAX ya da sayfa post edilerek tarayıcıya gönderilir.
Doğrulama işlemlerinde bileşenlerin 5 niteliği bulunur.
Bunlar
- validator
- rule
- messagefor
- message
- success
Validator: bu niteliğe static metodlar barındıran doğrulama sınıfının ismi verilmelidir. io dizininde filtler ve validator isimlerimlerinde hazır iki doğrulama sınıfı bulunmaktadır.
Rule : Validator niteliği ile bildirilen doğrulama sınıfının doğrulma işlemi için kullandığı metodun ismidir. (doğrulama metodu)
Message : Doğrulama işlemin sonucunun (false) yanlış olması durumunda verilecek olan uyarı mesajdır. Örneğin “Hatali email adresi girdiniz ! ”
Success Doğrulama işlemin sonucunun (true) doğru olması durumunda verilecek olan mesajdır. . Örneğin “email adresiniz doğrulandı ! ” Eğer doğrulama mesajı verilmek istenmiyorsa bu nitelik boş bırakılabilir.
Messagefor : message ve success ile belirtilen mesajların hangi bileşende görüntüleneceğidir.
FacesController varsayılan durum da bir doğrulama işleminin sonucu yanlış ise olay metotlarını işletmez . Doğrulama işleminin sonucu yanlış olduğu halde örneğin bir Clicked metodunun işletilmesini istiyorsanız FacesController ın setValidCallBack(boolean); metoduna true değerini vermeniz yeterlidir.
Doğrulama işleminin sonucunun doğru ya da yanlış olduğunu bileşenin isValid metodunun döndürdüğü değere bakarak anlaşılabilir.
Örnek Kullanıcı tarafından girilen e-mail Adresinin doğrulanması.
View görünüm dosyası
<faces> <@import prefix="f" taglib="phpf.ui.*"/> <f:form method="post"> E-Mail :<f:textbox validator="filter" rule="mail" success="Mail adresiniz doğrulandı" message=" Hatali email adresi girdiniz ! " messagefor="msgbox" /> <f:message id="msgbox"/> </f:form> </faces>
Doğrulama işlemi sonucu doğru ise msgbox isimli bileşende success ile belirtilen yanlış ise message ile belirtilen bilgi yer alır.
Filtler sınıfının metotları aşağıdaki gibidir.
- required
- url
- ip
- float
- int
- boolean
- regxp
Validator sınıfının metotları aşağıdaki gibidir.
- required
- equals
- minLength
- maxLength
- alpha
- alpha_numeric
- numeric
- integer
- betweenLength
- between
- boolean
- test














1 yorum
Remo Liechti diyor ki:
21:55 de 09 Mart 2010 (UTC 3)
Hey there!
Great stuff you got with php faces! Amazing I use java and JSF usually but almost no hoster has a proper java installation around for reasonable price. I just love your idea!
would it be possible to get a pdf with the documentation in it? It’s kind of boring to go to your page all the time since it’s not that fast actually
I’d like to print the PDF out and have it as a reference.
What I miss in your concept is validators and converters for forms as we have them in JSF, this is great!
All other stuff is very well done, amazing job! Especially the ORM and controllers, very handy.
I think it would be very cool if you could try to implement such components are rich faces has in JSF:
http://livedemo.exadel.com/richfaces-demo/index.jsp
especially drag and drop support would be gorgeous! also some kind of data table with filter and sort would be very cool, especially if it is connected to the great ORM you have. just putting in a list of entities and the table gets rendered, that be great!
unfortunately I’m not that a good php coder (doing java for years now but php style is somehow new to me) but I could think of supporting you in future I think this project is a good base to help php getting more object oriented based on events.
please let me know your thoughts!
Thanks for contributing this to the world!
Have a good one,
Remo