ADV: Faces has the following advantages over Struts:
Eliminated the need for a Form Bean
Eliminated the need for a DTO Class
Allows the use of the same POJO on all Tiers because of the Backing Bean
# A separate rendering model that defines how to render the components in various ways. For example, a component used for selecting an item from a list can be rendered as a menu or a set of radio buttons.
# An event and listener model that defines how to handle events generated by activating a component, such as what to do when a user clicks a button.
Managed BEAN :
Java Bean objects managed by a JSF implementation are called managed beans. A managed bean describes how a bean is created and managed. It has nothing to do with the bean's functionality.
Backing Beans | Managed Beans |
---|---|
A backing bean is any bean that is referenced by a form. | A managed bean is a backing bean that has been registered with JSF (in faces-config.xml) and it automatically created (and optionally initialized) by JSF when it is needed. |
The advantage of managed beans is that the JSF framework will automatically create these beans, optionally initialize them with parameters you specify in faces-config.xml, | |
Backing Beans should be defined only in the request scope | The managed beans that are created by JSF can be stored within the request, session, or application scopes |
View Object :
A view object is a model object used specifically in the presentation tier. It contains the data that must display in the view layer and the logic to validate user input, handle events, and interact with the business-logic tier.
Domain Object :
Domain object model is about the business object and should belong in the business-logic tier. It contains the business data and business logic associated with the specific business object.
Difference between JSP-EL and JSF-EL?
JSP-EL | JSF-EL |
---|---|
In JSP-EL the value expressions are delimited by ${…}. | In JSf-EL the value expressions are delimited by #{…}. |
The ${…} delimiter denotes the immediate evaluation of the expressions, at the time that the application server processes the page. | The #{…} delimiter denotes deferred evaluation. With deferred evaluation ,the application server retains the expression and evaluates it whenever a value is needed. |
Declare the managed beans in the faces-config.xml file?
The bean instance is configured in the
faces-config.xml
file:<managed-bean> <managed-bean-name>login</managed-bean-name> <managed-bean-class>com.developersBookJsf.loginBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean>
Page navigation (navigation rules) in faces-config.xml file ?
Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted. We can declare the page navigation as follows:
<naviagation-rule> <from-view-id>/index.jsp</from-view-id> <navigation-case> <from-outcome>login</from-outcome> <to-view-id>/welcome.jsp</to-view-id> </navigation-case> </naviagation-rule>
[If no navigation rule matches a given action, then the current page is redisplayed.]
JSF LIFE CYCLE
No comments:
Post a Comment