Hi, I'm writing a small web app for learning purpose only. My app has a login form which is used for login to different types of users(actually I have 2 types of users and each has different properties). I store info about users in database - first table(id, login, password), second table(id, info about user 1), third table(id, info about user 2). ID fields in second and third tables are foreign keys to ID field in first table. For each type of user I have a transfer object wich is actually a POJO.
I have a request scoped manged bean that handles the input of login and password and has to define on which page to redirect the user. So in action method of that bean I have to define the type of user and also instantiate a session scoped managed bean for specified type of user. Actually I have designed 2 session scoped beans for each type of user. That beans have such fields:
id - id of the user,
a few dao objects - for processing database access. Also that beans have such methods as
(of course each bean has its own
UserDTO) for accessing concrete properties of users.
I've found such solution to instantiate a bean inside other bean's action method:
Actually I can create a constructor of MyBean with parametres and pass the id(which was defined from login and password) of the user to it:
. But I think it's a bit tricky way, beacause
jsf is a pull-based framework and such solution is from push-based(we mannualy put beans into session).
Is there any other method to instantiate session scoped beans with certain parametres without using jsf specific code?(as one's says: good backing beans have no jsf specific code inside)
Or maybe my design approach for this problem is completly wrong? So advise better approach.
Thanks in advance