Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7613977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:17:06+00:00 2026-05-31T02:17:06+00:00

I am trying to create simple blog with jsf 2.0. It contains 2 classes:

  • 0

I am trying to create simple blog with jsf 2.0. It contains 2 classes:

BlogManager (in session scope)
Blog(in request scope)

@Named("blogManager")
@SessionScoped
public class BlogManager {
    private List<Blog> blogs;

    @ManagedProperty(value = "#{blog}")
    Blog blog;

    public BlogManager() {
        blogs = new ArrayList<Blog>();
    }

    public List<Blog> getBlogs() {
        return blogs;
    }

    public void setBlogs(List<Blog> blogs) {
        this.blogs = blogs;
    }

    public Blog getBlog() {
        return blog;
    }

    public void setBlog(Blog blog) {
        this.blog = blog;
    }

    public void addBlog() {
        blogs.add(blog);
    }

    public void removeBlog(Blog blog) {
        blogs.add(blog);
    }
}

the blog class:

@Named("blog")
@RequestScoped
public class Blog {

    private Integer id;

    private String title;
    private String text;
    private Date date;

    public Blog() {
        id = (int) System.currentTimeMillis();
    }

    private Integer readed;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Integer getReaded() {
        return readed;
    }

    public void setReaded(Integer readed) {
        this.readed = readed;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

}

then inside my xhtml form i am writing this thing:

<h:form>
            <fieldset>
                <legend>Blog</legend>
                <p>
                    Title:
                    <h:inputText value="#{blog.title}" />
                </p>
                <p>
                    Text:
                    <h:inputTextarea value="#{blog.text}" />
                </p>
                <p>
                    <h:commandButton action="#{blogManager.addBlog}" />
                </p>
            </fieldset>
        </h:form>

when i click submit it says blog target unreachable. It is request scope. I was thinking once jsf could not find the blog object then it creates and assigns user input to blog object. then i can see it in blogManager. But it does not work. what scope should i use for Blog class? And can i inject request scope in blogManager?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:17:08+00:00Added an answer on May 31, 2026 at 2:17 am

    Ideally, your Blog class should only be a POJO. And it should be a member of BlogManager. So the only bean you need will be
    BlogManager :

    @Named("blogManager")
    @SessionScoped
    public class BlogManager {
        private List<Blog> blogs;
    
        private Blog blog;
    
        public BlogManager() {
            blogs = new ArrayList<Blog>();
                blog = new Blog();
        }
    
        // getter setters for blog and blogs
    
        public void addBlog() {
            blogs.add(blog);
        }
    
        public void removeBlog(Blog blog) {
            blogs.add(blog);
        }
    }
    

    the blog class:

    public class Blog {
    
        private Integer id;
    
        private String title;
        private String text;
        private Date date;
        private Integer readed;
    
        public Blog() {
            id = (int) System.currentTimeMillis();
        }
    
        // getters-setters
    
    }
    

    And your xhtml :

    <h:form>
                <fieldset>
                    <legend>Blog</legend>
                    <p>
                        Title:
                        <h:inputText value="#{blogManager.blog.title}" />
                    </p>
                    <p>
                        Text:
                        <h:inputTextarea value="#{blogManager.blog.text}" />
                    </p>
                    <p>
                        <h:commandButton action="#{blogManager.addBlog}" />
                    </p>
                </fieldset>
            </h:form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm testing CodeIgniter, and trying to create a simple blog. The video tutorial on
I'm new to ASP.NET MVC and I'm trying to create a very simple blog
I am trying to create a simple blog that has code inclosed in <pre>
So I am teaching myself rails and I am trying to create simple blog
Im trying to create a simple pan and zoom app using silverlight 4, but
I am trying to create a simple dialog in MFC using Visual C++. My
I am trying to create a simple page that enters data in to a
I'm trying to create a simple BaSH-like grammar on ANTLRv3 but haven't been able
I'm trying to create a simple toggling sidebar using jquery, where it expands and
I am trying to create a simple mouseover effect using a combination of mouseover,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.