如何在jsf中将Primefaces Galleria与用户定义的对象一起使用

问题描述 投票:1回答:3

我想将当前的缩放库转换为Prime-faces画廊。我有以下代码。

1)profile.xhtml

<div class="profileImageDiv">
       <em:zoomGalleria showDocName="true" value="#{thumbImageMBean.documentReferenceThumbs}" />
        <a href="#{request.contextPath}/ui/ImageServlet?genericProfileDocRefId=#{generalEnquiryMBean.profileDocRefId}&amp;name=abc.jpg"
           class="group1">
          <h:graphicImage title="#{generalEnquiryMBean.profileDocRefId}"
                  value="/ui/ImageServlet?name=abc.jpg&amp;docRefId=#{generalEnquiryMBean.profileDocRefId}&amp;thumb=true"
                  alt="" width="137" height="138"/>
        </a>
      </div>

2)ThumbImageBean.java

@ManagedBean
@CustomScoped(value = "#{customScope}")
public class ThumbImageMBean extends BaseBean{


  ZoomGalleriaModel documentReferenceThumbs;

    public void setDocumentReferenceThumbs(ZoomGalleriaModel documentReferenceThumbs){
    this.documentReferenceThumbs = documentReferenceThumbs;
  }
 public ZoomGalleriaModel getDocumentReferenceThumbs() {
    return this.documentReferenceThumbs;
  }

3)ZoomgalleriaModel

 public class ZoomGalleriaModel {
  private List<GalleriaDocument> documentList;
  //setter getter 
    public void addGalleriaDocument(GalleriaDocument galleriaDocument){
    documentList.add(galleriaDocument);
  }

4)GalleriaDocument

  public class GalleriaDocument implements Serializable{

  private long docRefId;
  private String docDescription;
  private byte[] document;
  private Date documentDate;
  private String userName;
//setter and getter and constructor
  }

我尝试通过以下代码使用Primefaces Galleria。 PrimeFaces Galleria code

<p:galleria value="#{thumbImageMBean.documentReferenceThumbs.documentList.toArray()}"     var="galleriaDoc" panelWidth="500" panelHeight="313" showCaption="true"> //primefaces galleria required array of string but i had List of objects   

    <p:graphicImage name="demo/images/nature/#{galleriaDoc}" alt="Image Description for #{galleriaDoc}" title="#{galleriaDoc}"/>
</p:galleria>

但是它不起作用,我不是JSF专家,所以要感谢每个建议。

PS:PrimeFaces版本3.0

java jsf primefaces galleria
3个回答
1
投票

看起来您的documentList是List<GalleriaDocument>。对于初学者,您可能会失去toArray()。


1
投票

Primefaces galleria接受String(图像名称)列表,并且您正在传递对象列表。您可以将其转换为String(docRefId的列表)


0
投票

以下代码对我有用,但是description(title + date)没有显示。 PrimeFaces版本为3.1

© www.soinside.com 2019 - 2024. All rights reserved.