Saturday, July 12, 2008

Inside Jsf(User Interface-Bean Interaction)

We can build our page by using jsf standart tags. Then we have to control these components with our beans and we have to control the behaviour of it. How?

We are doing this wtih backing beans related to our jsf pages connected by faces-config.xml.

So what is faces-config.xml?

This file is used to manage and configure our view. We are connecting our backing beans to our pages by using these lines;

1 <managed-bean>
2 <managed-bean-name>baseMBean
3 <managed-bean-class>
4 tr.gov.ibb.beans.BaseMBean
5 </managed-bean-class>
6 <managed-bean-scope>request
7 </managed-bean>

Line 1:"Here, a managed bean is starting"
Line 2:"Here, Beans name="baseBean" and you can use this declaration in your pages like"
Example:="<ice:inputText value="#{baseBean.entity.property}" />"
Line3:This managed Beans class is loocated in this package
Line4: Managed beans package name comes here as "com.oracle.beans.BaseBean"
Line5: Closing tag

Line6: This line is very important!! Managed beans scope is defined. And there could be 4 states for a managed bean. These are: "Request, Session, Application and None" I will explain them later.
Line7:Closing tag

After doing some configuration now we can control our view with our Bean.

Inside JSF (UI Components)

Let's have a look about jsf pages.

User Interface Components;

1-)These objects manages the ineraction between the user and program.
2-)Stored as a tree at server side
3-)Their state is stored
4-)Standart Components:outputText, outputLabel, commandButton, panelGrid, datatable, selectOneMenu, selectoneRadio, selectManyMenu, selectBooleanCheckbox, menu, tabbedPane, fileUpload, tree, etc..

And also these components are extended by third parties like IceFaces, RichFaces, MyFaces etc..

And I am using Icefaces for a long time. I started with version 1.6 and now using the latest version. Ajax enabled components are looking good but people have to be aware of what they are using.

Why JSF(Java Server Faces)?

First of all I have to say that there exists a lot of solutions to web development and Jsf is an alternative and powerful solution for our business.

The promise of Jsf is to bring rapid user interface development to server side Java.

And let's look inside of it;

What is Jsf?

Jsf is a standart web user interface framework for Java.

Key JSF consepts:
1-)UI (User Interface) components
2-)Renderers
3-)Backing beans(Connecting JSF tags to application logic)
4-)Validators
5-)Converters
6-)Events and Listeners
7-)Expression Language
8-)Messages
9-)Navigations