主要面孔重新装载画廊



参考:http://www.primefaces.org/showcase/ui/galleria.jsf

我的页面:

<p:galleria id="merchant-gallery" value="#{testController.imageIds}" var="item" autoPlay="false" >  
    <p:graphicImage width="300" value="#{imageStreamer.image}" >
        <f:param name="id" value="#{item}" />
    </p:graphicImage>
</p:galleria>  

我尝试封闭<p:galleria>在一个形式,并添加了一个<p:remoteCommand name="updateme" update="@form"/>,但调用updateme后,它只是简单地使画廊空白。

*更新

testController bean:

public List<Integer> getImageIds() {
    int aId = (Integer) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("user_id");
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("TEST2PU");
    EntityManager em = emf.createEntityManager();
    TypedQuery<Merchant> tp = em.createQuery("SELECT a FROM Account a WHERE a.id = :id", Account.class);
    tp.setParameter("id", aId);
    current = tp.getSingleResult();
    Collection rawPhotoCollection = current.getPhotoCollection();
    imageIds = new ArrayList<Integer>(rawPhotoCollection);
    List<Photo> photoList = new ArrayList<Photo>(rawPhotoCollection);
    for (int i = 0; i < photoList.size(); i++) {
        int imageId = photoList.get(i).getId();
        imageIds.set(i, imageId);
    }
    return imageIds;
}

imageStreamer bean:

@EJB
private test.controller.photo.PhotoFacade ejbFacade;
public StreamedContent getImage() throws IOException {
    FacesContext context = FacesContext.getCurrentInstance();
    if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
        return new DefaultStreamedContent();
    } else {
        Map<String, String> param = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
        String id = param.get("id");
        Photo image = ejbFacade.find(Integer.valueOf(id));
        return new DefaultStreamedContent(new ByteArrayInputStream(image.getImage()));
    }
}

我重新设计了你的例子,有同样的问题。它与您的上传或远程命令无关。我觉得这是一种长脸虫。参见http://code.google.com/p/primefaces/issues/detail?id=4840了解类似问题。当我输入

命令时
PrimeFaces.cw('Galleria','widget_companydetail_merchant-gallery',{id:'companydetail:merchant-gallery',transitionInterval:0,panelWidth:640,panelHeight:480,custom:false},'galleria');

在firebug控制台中,画廊重新出现。因此,当更改远程命令并添加javascript以完成时,它可以工作。

<p:remoteCommand name="updateme" update="@form" oncomplete="PrimeFaces.cw('Galleria','widget_companydetail_merchant-gallery',{id:'companydetail:merchant-gallery',transitionInterval:0,panelWidth:640,panelHeight:480,custom:false},'galleria');"/>

相关内容

  • 没有找到相关文章

最新更新