The following tutorial is an example of parsing JSON objects and displaying them on a web page using JSF 2.1 and PrimeFaces 2.2 which is a rich-component framework for JSF adding AJAX and Web 2.0 capabilities to your web application.
What you need for this tutorial
Oracle JDK 1.6 or later
Netbeans 7.0 or later
The following tutorial is an example of parsing JSON objects and displaying them on a web page using JSF 2.1 and PrimeFaces 2.2 which is a rich-component framework for JSF adding AJAX and Web 2.0 capabilities to your web application.
What you need for this tutorial
Oracle JDK 1.6 or later
Netbeans 7.0 or later
[adsenseyu1]
Bu yazımda döviz kurları bilgi akışı içeren bir JSON nesnesini işleyip, bir web sayfası üzerinde JSF 2.1 framework’ü ve JSF için bir zengin bileşen kütüphanesi olan PrimeFaces 2.2 kullanarak AJAX ve Web 2.0 özellikleri ile nasıl görünteleyebileceğimizi göreceğiz.
Bu öğretiyi uygulamak için nelere ihtiyacınız var
- Oracle JDK 1.6 veya sonraki bir sürümü
- Netbeans 7.0 veya daha yeni bir sürümü (farklı bir editör ve geliştirme ortamı kullanmayı tercih ederseniz, Gerekli kütüphane ve bileşenlerin tümünü manuel olarak projeye dahil etmeniz gerekebilir. Bkz. sonraki bölüm)
- Tomcat 7
Kullanılan teknoloji ve kütüphaneler
- JSF 2.1 (Mojarra 2 kütüphaneleri yani jsf-api.jar, jsf-impl.jar, jstl.jar ve standard.jar)
- PrimeFaces 2.2.1
- JSON (Java için)
- commons-logging-1.1.1.jar
- log4j-1.2.16.jar
- httpcore-4.1.4.jar
- httpclient-4.1.3.jar
Projeyi JSF 2 ve PrimeFaces desteği dahil olacak şekilde hazırlama
Netbeans’i açın ve aşağıdaki adımları sırayla izleyin:

Great tutorial, G, thanks! With HTML 5 and AJAX, we’ll need JSON more than ever.
How/when is exchangeRatesBean instantiated?
A Managed Bean is instantiated as soon as a JSF action references a method contained in it, in the case of the ExchangeRatesBean, it’s invoked as index.xhtml is called in the browser.
Great read, thanks gokhan
A good tutorial for beginning JSF. Can you provide a download for the project files?
I put the complete NetBeans project(s) in the Downloads section under the Tutorial files category.
Can I ask the reason why using ApplicationScoped Managed Bean?
Sure. The main strategy here is pulling the exchange rate data once and providing that very data to all visitors (until someone invokes the Refresh action, which will benefit every new visitor) as there’s a very very little chance that there would be dramatic changes in the rates. You could change to scope of the managed bean to « session » (i.e. @SessionScoped) or even lower the scope as low as to the « request » (@RequestScoped) but I didn’t want to add extra load to the service (data) provider for a free service and therefore chose to avoid pissing them off.