目前,我成功地从我的数据库使用数据表与排序/过滤功能显示图像元数据。 下面我的数据表我使用的是第三方图像的CoverFlow(成功显示我的图片http://www.jacksasylum.eu/ContentFlow/ )。 我使用的是相同的列表在这一点上同时显示。 我在我的数据表内筛选我的数据后,我需要动态地更新我的形象名单在我的CoverFlow与筛选数据表的结果。
什么是做到这一点使用PrimeFaces的最佳方式? 会有人能够指出我对工作的例子吗?
这里是我的代码:
screenshotData.xhtml
<h:form>
<p:dataTable var="scrshot" value="#{screenshots}" paginator="true" rows="8"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
rowsPerPageTemplate="5,10,15" widgetVar="dataTable" draggableColumns="true"
emptyMessage="No screenshot data found with given criteria">
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Search all fields:"/>
<p:inputText id="globalFilter" onkeyup="dataTable.filter()" style="width:150px" />
</p:outputPanel>
</f:facet>
<p:column headerText="Time" sortBy="#{scrshot.time}" filterBy="#{scrshot.time}" filterMatchMode="startsWith">
<h:outputText value="#{scrshot.time}" />
</p:column>
<p:column headerText="Id" sortBy="#{scrshot.id}" filterBy="#{scrshot.id}" filterMatchMode="startsWith">
<h:outputText value="#{scrshot.id}" />
</p:column>
<p:column headerText="User" sortBy="#{scrshot.user}" filterBy="#{scrshot.user}" filterMatchMode="startsWith">
<h:outputText value="#{scrshot.user}" />
</p:column>
</p:dataTable>
</h:form>
<br/>
<h:form>
<p:outputPanel id="imgBlock" layout="block">
<div class="ContentFlow" style="width: 1400px; height: 500px" align="center">
<div class="loadIndicator"><div class="indicator"></div></div>
<div class="flow">
<a4j:repeat var="img" value="#{screenshots}" rendered="true">
<div class="item">
<img class="content" id="images" src="ImgServlet?id=#{img.id}" title="#{img.time}" draggable="true"/>
<div class="label">#{img.id}</div>
</div>
</a4j:repeat>
</div>
<div class="globalCaption"></div>
<div class="scrollbar"><div class="slider"><div class="position"></div></div></div>
</div>
</p:outputPanel>
</h:form>
...............
Screenshot.java
@Entity
@XmlRootElement
@Table(name="imgTable", uniqueConstraints = @UniqueConstraint(columnNames = "id"))
public class Screenshot implements Serializable, PhotoInterface {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
private String user;
private Timestamp time;
-------- Getters/Setters ---------
ScreenshotListProducer.java
@RequestScoped
public class ScreenshotListProducer {
@Inject
private EntityManager em;
private List<Screenshot> screenshots;
@Produces
@Named
public List<Screenshot> getScreenshots() {
return screenshots;
}