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

  • Home
  • SEARCH
  • 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 7842361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:18:05+00:00 2026-06-02T16:18:05+00:00

Does it make sense to use Entities as JSF Backing Beans? @Entity @ManagedBean @ViewScoped

  • 0

Does it make sense to use Entities as JSF Backing Beans?

@Entity
@ManagedBean
@ViewScoped
public class User {

    private String firstname;
    private String lastname;

    @EJB
    private UserService service;

    public void submit() {
        service.create(this);
    }

    // ...
}

Or is it better to keep them separately and transfer the data from the backing bean to the entity at the end?

@ManagedBean
@ViewScoped
public class UserBean {

    private String firstname;
    private String lastname;

    @EJB
    private UserService service;

    public void submit() {
        User user = new User();
        user.setFirstname(firstname);
        user.setLastname(lastname);
        service.create(user);
    }

    // ...
}
  • 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-06-02T16:18:06+00:00Added an answer on June 2, 2026 at 4:18 pm

    You could do so. It’s technically possible. But it does (design)functionally not make any sense. You’re basically tight-coupling the model with the controller. Usually the JPA entity (model) is a property of a JSF managed bean (controller). This keeps the code DRY. You don’t want to duplicate the same properties over all place, let alone annotations on those such as bean validation constraints.

    E.g.

    @ManagedBean
    @ViewScoped
    public class Register {
    
        private User user;
    
        @EJB
        private UserService service;
    
        @PostConstruct
        public void init() { 
            user = new User();
        }
    
        public void submit() {
            service.create(user);
        }
    
        public User getUser() {
            return user;
        }
    
    }
    

    with this Facelets page (view):

    <h:form>
        <h:inputText value="#{register.user.email}" />
        <h:inputSecret value="#{register.user.password}" />
        <h:inputText value="#{register.user.firstname}" />
        <h:inputText value="#{register.user.lastname}" />
        ...
        <h:commandButton value="Register" action="#{register.submit}" />
    </h:form>
    

    See also:

    • What components are MVC in JSF MVC framework?
    • JSF Controller, Service and DAO
    • Contradictory explanations of MVC in JSF
    • JSF 2 reusing the validation defined in the JPA entities?
    • why shouldn't entity bean be managed by JSF framework?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does it make sense to use SQL Server Compact for a desktop application? How
Does it make sense to use interfaces for your domain object factories by default,
does it make sense to use an Filecache when using Sqlite as Database ?
Does it make sense to use RIA Services as a service provider to an
When does it make sense to use Loop fission/distribution if I am compiling for
Does it make sense to use a ThreadPool with a poolsize of just 1
I just want to ask, does it make sense to use both a PHP
I'm really interested how lambda functions are used. Does it make sense to use
Does it make sense to use Qt for increasing the productivity in an MFC
Does it make sense to make use of $.getScript(); in jQuery to do something

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.