以下の問題で立ち往生しているため、助けを求めたいと思います。最初に言わなければならないもう 1 つのことは、私は JSF 開発の初心者だということです。
JSF、PrimeFaces、Hibernate、および PostgreSQL を使用しています。
現在、新規ユーザーの登録フォームに取り組んでいます。このテスト アプリケーションは 4 ページで構成されています。最初のページには基本的な静的情報が含まれており、2 ページ目はユーザーに関する主な情報を入力するためのフォームであり、3 ページ目ではユーザーが自由な期間を選択します (これが私の問題です!)。情報。
3 ページ目:
これは、ラジオ チェックボックスと単一選択を備えた PrimeFaces DataTable です。PrimeFaces ショー ケースとBalusC の Datatables チュートリアルに従いました。問題は、データベースからのデータが取り込まれたリストを表示できないことにあります。主な問題は、選択された行を格納する必要があるプロパティprivate CollectionTerm selectedTermにあります。
エラーログ:
[javax.el.ELException: Error reading 'dataList' on type de.ibmt.upb.model.CollectionTerm] with root cause
org.postgresql.util.PSQLException: ERROR: column collection0_.selectedterm does not exist
Position: 78
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:302)
at sun.reflect.GeneratedMethodAccessor38.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at com.sun.proxy.$Proxy25.executeQuery(Unknown Source)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2031)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1832)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1811)
at org.hibernate.loader.Loader.doQuery(Loader.java:899)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:341)
at org.hibernate.loader.Loader.doList(Loader.java:2516)
at org.hibernate.loader.Loader.doList(Loader.java:2502)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2332)
at org.hibernate.loader.Loader.list(Loader.java:2327)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:490)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1247)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at de.ibmt.upb.model.CollectionTerm.loadDataList(CollectionTerm.java:90)
at de.ibmt.upb.model.CollectionTerm.getDataList(CollectionTerm.java:83)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:87)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:169)
at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:96)
at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:246)
at javax.faces.component.UIData.getValue(UIData.java:2028)
at org.primefaces.component.datatable.DataTable.getValue(DataTable.java:867)
at org.primefaces.component.api.UIData.getDataModel(UIData.java:579)
at org.primefaces.component.api.UIData.setRowModel(UIData.java:409)
at org.primefaces.component.api.UIData.setRowIndex(UIData.java:401)
at javax.faces.component.UIData.encodeEnd(UIData.java:1690)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:63)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:47)
at org.primefaces.component.fieldset.FieldsetRenderer.encodeContent(FieldsetRenderer.java:90)
at org.primefaces.component.fieldset.FieldsetRenderer.encodeMarkup(FieldsetRenderer.java:72)
at org.primefaces.component.fieldset.FieldsetRenderer.encodeEnd(FieldsetRenderer.java:46)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:580)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:762)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:758)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:758)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1900)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:115)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
マネージドBean:
@ManagedBean
@Entity
@Table(name="COLLECTION_TABLE")
public class CollectionTerm implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private Integer c_id;
private Date dateCollection;
private Time timeCollection;
@OneToMany(mappedBy="coll")
private Collection<UserDetails> userDetails = new ArrayList<UserDetails>();
@ElementCollection(targetClass=CollectionTerm.class)
private List<CollectionTerm> dataList;
private CollectionTerm selectedTerm;
public CollectionTerm() {
}
///// getters and setters /////
public List<CollectionTerm> getDataList() {
if (FacesContext.getCurrentInstance().getRenderResponse()) {
loadDataList();
}
return dataList;
}
private void loadDataList() {
Session session = HibernateUtil.getSessionFactory().openSession();
dataList = session.createQuery("from CollectionTerm").list();
}
}
JSF:
<h:form id="collection">
<p:fieldset legend="Date and time">
<p:dataTable id="collection" value="#{coll.dataList}" var="coll" rowKey="#{coll.c_id}" selection="coll.selectedTerm">
<p:column selectionMode="single" style="width:2%" />
<p:column >
#{coll.timeCollection}
</p:column>
<p:column>
#{coll.dateCollection}
</p:column>
<p:column>
#{coll.c_id}
</p:column>
</p:dataTable>
<p:commandButton value="Back" action="registrationback" ajax="false" />
<p:commandButton value="Next" action="recap" ajax="false" />
<p:commandButton value="Test" action="testcollection" ajax="false" />
</p:fieldset>
</h:form>
Faces-config:
<managed-bean>
<managed-bean-name>coll</managed-bean-name>
<managed-bean-class>de.ibmt.upb.model.CollectionTerm</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>userService</managed-bean-name>
<managed-bean-class>de.ibmt.upb.model.UserDetails</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>term</property-name>
<value>#{term}</value>
</managed-property>
<managed-property>
<property-name>coll</property-name>
<value>#{coll}</value>
</managed-property>
</managed-bean>
私が間違っていることは何ですか?
返信や推奨事項をありがとう!