简体   繁体   English

SelectOneMenu更改时,PrimeFaces更新图库

[英]PrimeFaces update gallery when SelectOneMenu changes

I am using Primefaces 3.5. 我正在使用Primefaces 3.5。 I have the following code: 我有以下代码:

<p:panel id="containerSelectionPanel" header="Container Selection">
    <h:form id="containerSelectionForm">
        <p:selectOneMenu value="#{manageContainersBean.selectedContainer}">
            <f:selectItems value="#{manageContainersBean.containerList}" var="container" itemLabel="#{container.name}" />
            <p:ajax update=":componentSelectionPanel" />
        </p:selectOneMenu>
    </h:form>
</p:panel>

<p:panel id="componentSelectionPanel" header="Component Selection">
    <h:form id="componentSelectionForm">
        <p:galleria id="componentGallery" var="component"
            value="#{manageContainersBean.selectedContainer.components}">
            <p:graphicImage value="#{component.preview}" title="#{component.name}" alt="#{component.name}"></p:graphicImage>
        </p:galleria>
    </h:form>
</p:panel>

On startup of the website the gallery gets shown correctly. 在网站启动时,图库会正确显示。 However, if I change the selection in the SelectOneMenu the gallery is just empty (nothing gets shown, the panel for "Component Selection" itself is empty). 但是,如果我在SelectOneMenu更改选择,则画廊只是空的(什么都没有显示,“组件选择”的面板本身是空的)。

The updating through the AJAX request works. 通过AJAX请求进行的更新有效。 The list of components is retrieved upon update , the preview as well as name are requested as desired. 在更新时检索组件列表,并根据需要请求预览和名称。 However, the HTML code generated for the updated gallery contains very few lines, way less than when loading the gallery initially, see here: 但是,为更新的图库生成的HTML代码包含很少的行,比最初加载图库时要少得多,请参见此处:

<ul class="ui-galleria-panel-wrapper">
    <li class="ui-galleria-panel ui-helper-hidden">
        <img id="j_idt28" alt="Have lunch" title="Have lunch">
    </li>
    <li class="ui-galleria-panel ui-helper-hidden">
        <img id="j_idt28" alt="Have brunch" title="Have brunch">
    </li>
</ul>

As can be seen, the newly selected container is fetched, though and the images are somewhat updated (but the inital gallery contains way more code). 可以看出,虽然新选择的容器已获取,但是图像有所更新(但初始库包含更多代码)。

I already tried updating the complete form instead of only the gallery: same result. 我已经尝试更新完整的表格,而不只是更新图库:相同的结果。 I tried moving the gallery out of the form itself: same result. 我试图将画廊移出表格本身:同样的结果。 I tried using a Javascript update from the Browser console as tried here , nothing happens. 我尝试从浏览器控制台使用Javascript更新,如此处所示 ,没有任何反应。

Does someone have a solution to this problem? 有人可以解决这个问题吗?

Update: I checked the server response, that gets send when the gallery should be updated. 更新:我检查了服务器响应,该响应在画廊应该更新时发送。 It contains exactly the same code as the initial response (when the gallery works), so there must be something wrong with JSF during rendering the response. 它包含与初始响应(当画廊工作时)完全相同的代码,因此JSF在呈现响应时一定有问题。 But still no clue on how to handle this. 但是对于如何处理这个问题仍然一无所知。

Edit: general thing: the form should not be updated, but the complete panel. 编辑:普通的事情:该窗体不应该更新,而是完整的面板。

Regards, bobbel 问候,鲍勃

I found the issue being reported here . 我发现这里正在报告该问题。

The temporary solution then is to modify the ajax request in the containerSelectionForm as follows: 然后,临时解决方案是按如下方式修改containerSelectionForm的ajax请求:

<p:ajax 
    update=":componentSelectionPanel"           
    oncomplete="PrimeFaces.cw('Galleria','widget_componentSelectionForm_componentGallery',{id:'componentSelectionForm:componentGallery'}" />

In the call of PrimeFaces.cw() be sure to include galleria parameters like panelWidth in the object, that already contains the id . 在调用PrimeFaces.cw()确保在对象中包括panelWidth参数(例如panelWidth ,该参数已经包含id

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM