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 7523251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:44:36+00:00 2026-05-30T02:44:36+00:00

I am trying to implement login method with JSF, EJB and JPA. My current

  • 0

I am trying to implement login method with JSF, EJB and JPA. My current approach is that I am passing login and password from jsf page to managed bean, method login() in bean is then fired when user presses a button.

Then the method login is calling authenticate method in EJB bean and here comes my question. I have two types of users(two entities, Student and Teacher), so what should be the returning value of EJBs method in case that the user was found?

I was thinking about returning the id of entity and then retrieve my entity with that id in the managed bean. Or do it somehow with polymoformism, but my entities are already extending the AbstractEntity class(which contains only id and setters/getters) and I don’t see any way how it could help me with my problem. The goal is to have my user entity after succesfull login in the original managed bean.

Thanks a lot for answers, this is a maybe stupid question but I am really out of ideas:-)

  • 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-30T02:44:38+00:00Added an answer on May 30, 2026 at 2:44 am

    You’ve basically 2 options:

    1. Let both Student and Teacher extend a common abstract class like Person or User. That works of course only the best if there are (almost) only common methods.

    2. Create another class like Person or User which can take Student or Teacher as constructor argument and let all methods delegate to the wrapped instance. You should then model this class according to what the views need. You of course can’t and don’t want to do an instanceof in EL expressions.

      This can further be abstracted by creating 3 classes: one base abstract wrapper class which the views need and two concrete implementations, one which should wrap Student and other which should wrap Teacher. This allows for more easy extension when you want to add again another kind of user.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to implement a login method for mongodb , using python (pymongo) and
I have a class that uses a method from a bean. I'm trying to
I'm trying to implement OpenId login for a web application. Whenever new user who
I'm trying to implement a reconnect logic for a wcf client. I'm aware that
Am trying to implement a generic way for reading sections from a config file.
I'm trying to implement a browser auto-complete feature for my application Login view. However
So I'm trying to implement a more efficient method of calculating 2^n . I
I'm trying to implement the configuration but it never redirects me to my login.html
I'm trying to implement some customize login through the custom methods in Django's models.
I'm trying to implement a method similar to what mytunescontroller uses to check if

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.