Tuesday, February 8, 2011

Annotations For Managed Beans

Thanks to annotations you don't have to mess with xml configuration files as much.
Here is an example of how to use ManagedBean annotations for your managed beans.

Faces Config Entries:

</managed-bean\>
</managed-bean-name\>myBean\</managed-bean-name\>
</managed-bean-class\>org.mybeans.MyBean</managed-bean-class\>
</managed-bean-scope\>session</managed-bean-scope\>
</managed-bean\>

Annotation Alternative:

@ManagedBean(name="myBean")
@SessionScoped
public class MyBean {

}

That's all!