jsf - primefaces reload galleria -
reference: http://www.primefaces.org/showcase/ui/galleria.jsf
my page:
<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>
i tried enclosing <p:galleria>
in form , added <p:remotecommand name="updateme" update="@form"/>
after calling updateme make galleria blank.
*update
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 account 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); (int = 0; < 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())); } }
i reworked example , have same issue. not related upload or remotecommand. think bug in primefaces. see http://code.google.com/p/primefaces/issues/detail?id=4840 similar issue. when command
primefaces.cw('galleria','widget_companydetail_merchant-gallery',{id:'companydetail:merchant-gallery',transitioninterval:0,panelwidth:640,panelheight:480,custom:false},'galleria');
in firebug console, galleria reappears. when changing remotecommand , adding javascript oncomplete works.
<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');"/>
Comments
Post a Comment