0

I'm trying to build an application with JSF 2.2 and it's getting quite difficult, I've reached a point that I need a single form to multiple ManagedBeans;

turned to the inheritance way:

inheritance

Teacher and Student as ManagedBeans and User as their superclass, but doing so a problem was found, the User is abstract (obviously) and I'm stuck here; if it was a non-JSF application, I could use constructors, but it isn't and I can't figure out how getters and setters would help in this case. I also tried to use reflection inside the Filter (who holds the requests for pages that need login), but it doesn't solved the problem at all.

What I need is a way to make multiple types of users login in the same form.
The form structure:

<h:form>
    <p:outputLabel for="username" value="#{msgs.loginUsername}"/><p:inputText id="username" required="true" value="#{user.username}"/>
    <p:outputLabel for="password" value="#{msgs.loginPassword}"/><p:password id="password" required="true" value="#{user.password}"/>
    <p:commandButton action="#{user.login}" value="#{msgs.loginLogin}"/>
</h:form>
ptkato
  • 668
  • 1
  • 7
  • 14
  • 1
    This is a usual login mechanism where you do not need an abstract super class. It appears that you are trying to assign different users a different authority(ies)/role(s) but this is a different thing. – Tiny Mar 22 '15 at 18:10
  • About that, also, you're right, I don't want users, I want types of users. Get rid of the abstract class `User` isn't an option, it'll allow users without roles. – ptkato Mar 22 '15 at 18:44
  • 1
    A 'concrete' user also can exist without explicit roles... But [this stackoverflow post](http://stackoverflow.com/questions/15451422/how-to-use-cdi-qualifiers-with-multiple-class-implementations) might help – Kukeltje Mar 23 '15 at 13:40

0 Answers0