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:
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>