New Features in JSF 2.0

With many new features, JSF 2.0 is an evolution from 1.2, but it’s also a step forward—for example, in
terms of PDL, where Facelets is preferred to JSP. New features of JSF 2.0 include the following:

• An alternative viewing technology to JSP based on Facelets

• Easier navigation between pages with implicit and conditional navigation

• JSF has been using POST HTTP requests intensively; this new release brings back GET requests as a first-class citizen (allowing users to bookmark pages)
• A new resource-handling mechanism (for images, CSS, JavaScript files, and so on)

• Additional scopes (view scope, flash and component scope)

• Easy development with annotations for managed beans, renderers, converters,validators, and so on.

• Reducing XML configuration by exploiting annotations and configuration by exception (faces-config.xml is optional)

• Ajax support

• Better error handling (provides information such as line numbers and not just a stack trace)

• Easy component development

I will also point some differences between JSF 1.2 and JSF 2.0
JSF 1.2 JSF 2.0
Pure JSF without any bells and whistles specific to JSF 2 (Ajax stuff and such) – the difference while in JSF 2.0 this has become mostly unnecessary. But that is not really where
won’t be that great. What you have additionally in JSF 1.2 is the need to declare everything i you lose the time.Only when you start to think about custom components will JSF
n a faces-config.xml file. 2.0 give you faster development cycle because it has made easier through facelets.
It take little more time than JSF 2.0 It can save your time compared to JSF 1.2

Access one Managed Bean from another in JSF 2.0 | Techartifact

Requirement- Access one Managed Bean from another in JSF

Solution- There are two ways-

Dependency Injection

We can use JSF 2 @ManagedProperty annotation

In the managed bean add a @ManagedProperty annotation to the related property

@ManagedBean(name="currentBean")
@RequestScoped
public class CurrentBean 
{

    @ManagedProperty(value="#{requiredBean}")
    private RequiredBean requiredBean;

    public RequiredBean getRequiredBean()
    {
        return requiredBean;
    }

    public void setRequiredBean(RequiredBean requiredBean)
    {
        this.requiredBean= requiredBean;
    }

    // ....


}

Usingthrough faces-config.xml

<managed-bean>
   <managed-bean-name>requiredbBean</managed-bean-name>
   <managed-bean-class>vinay.common.RequiredBean</managed-bean-class>
   <managed-bean-scope>session</managed-bean-scope>
 </managed-bean>

 <managed-bean>
   <managed-bean-name>currentBean</managed-bean-name>
   <managed-bean-class>vinay.common.CurrentBean</managed-bean-class>
   <managed-bean-scope>request</managed-bean-scope>
   <managed-property>
     <property-name>requiredbBean</property-name>
     <value>#{requiredbBean}</value>
   </managed-property>
 </managed-bean>

Following are the constraints:

-> The current bean must have scope which is the same as or shorter than the required bean
-> The using bean must have a property-setter method which takes the required bean as a parameter
-> The beans cannot have managed dependencies on each other.