与单个表单相关的两个ManagedBeans

时间:2015-03-22 17:49:17

标签: jsf primefaces jsf-2.2 solid-principles

我正在尝试使用JSF 2.2构建一个应用程序并且它变得相当困难,我已经达到了一个点,我需要一个表单到多个ManagedBeans;

转向继承方式:

inheritance

TeacherStudent作为ManagedBeans和User作为他们的超类,但是这样做了一个问题,User是抽象的(显然),而我是'我被困在这里;如果它是一个非JSF应用程序,我可以使用构造函数,但它不是,我无法弄清楚getter和setter在这种情况下如何帮助。我还尝试在Filter中使用反射(谁持有需要登录的页面的请求),但它根本没有解决问题。

我需要的是一种让多种类型的用户以相同的形式登录的方法 表单结构:

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

0 个答案:

没有答案
相关问题