jsf保持一对多关系的基本问题

时间:2013-03-28 15:05:19

标签: jsf java-ee jpa facade

我是JPA和Java EE的新手。我在两个实体之间有一对多的关系(问题==<答案)。我使用NetBeans生成实体,并使用PrimeFaces生成sessionBeans和控制器。

现在我只想修改JSF“创建”页面,同时创建问题及其答案。

以下是我正在使用的代码:

<h:panelGroup id="display">
                <p:panelGrid columns="2" rendered="#{questionController.selected != null}">

                    <p:outputLabel value="#{bundle.CreateQuestionLabel_corpsquestion}" for="corpsquestion" />
                    <p:inputText id="corpsquestion" value="#{questionController.selected.corpsquestion}" title="#{bundle.CreateQuestionTitle_corpsquestion}" />

                    <p:outputLabel value="#{bundle.CreateQuestionLabel_codetheme}" for="codetheme" />
                    <p:selectOneMenu id="codetheme" value="#{questionController.selected.codetheme}" required="true" requiredMessage="#{bundle.EditQuestionRequiredMessage_codetheme}">
                        <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                        <f:selectItems value="#{themeController.items}"
                                       var="codethemeItem"
                                       itemValue="#{codethemeItem}"
                                       itemLabel="#{codethemeItem.description.toString()}"
                                       />
                        <f:converter binding="#{themeConverter}"/>
                    </p:selectOneMenu>
                    <p:outputLabel value="#{bundle.CreateReponseLabel_corpsreponse}" for="corpsreponse" />
                    <p:inputText id="corpsreponse" value="#{reponseController.selected.corpsreponse}" title="#{bundle.CreateReponseTitle_corpsreponse}" />
                </p:panelGrid>
                <p:commandButton actionListener="#{questionController.saveNew}" value="#{bundle.Save}" update="display,:QuestionListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,QuestionCreateDialog);"/>
                <p:commandButton value="#{bundle.Cancel}" onclick="QuestionCreateDialog.hide()"/>
            </h:panelGroup>

更新: 我试图只提供一个问题的答案用于测试目的。问题是,当我点击“保存”没有任何反应,没有数据保存到数据库中,并引发以下异常:

javax.el.PropertyNotFoundException: /Admin/question/Create.xhtml @32,159 
value="#{reponseController.selected.corpsreponse}": 
Target Unreachable, 'null' returned null

0 个答案:

没有答案
相关问题