Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Spring with JSF integaration

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 155
    Comment on it

    JavaServer Faces (JSF):- JSF is an MVC web framework which focus on or we can say that it's objective is to built user interfaces for Java web application similar to the JSP(Java Server Pages). The JSF comes with 100+ ready UI tags to build the UI for the web Applications.

    package com.evon.user;
    public interface User{
        public String getMessage();

    package com.evon.user.impl;
    import javax.inject.Named;
    import org.springframework.stereotype.Service;
    import com.evon.user.User;
    public class UserImpl implements User{
        public String getMessage() {
            return "JSF 2 + Spring Integration";

    package com.evon;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;
    import javax.inject.Inject;
    import javax.inject.Named;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.context.annotation.Scope;
    import org.springframework.stereotype.Component;
    import com.evon.user.User;
    public class UserBean {
        User user;
        public void setUser(User user) {
            this.user = user;
        public String printMsg() {
            return user.getMessage();


    <?xml version="1.0" encoding="UTF-8"?>
    <faces-config xmlns=""


    <beans xmlns=""
        <context:component-scan base-package="com.evon" />


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    <html xmlns=""   
            <h1>JSF 2.0 Integration with Spring </h1>

    The #{..} indicate that is JSF expression language(el), in this case, #{userBean.printMsg()}, when we hit url http://localhost:8080/JavaServerFaces/. The JSF will find the userBean and set the value via the setUser() method. When default.xhtml page is displayed JSF will find the same session userBean again and display the name property value via the printMsg() method.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: