SelectOneMenu更改时,PrimeFaces更新图库 [英] PrimeFaces update gallery when SelectOneMenu changes

查看:65
本文介绍了SelectOneMenu更改时,PrimeFaces更新图库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Primefaces 3.5.我有以下代码:

I am using 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>

在网站启动时,图库会正确显示.但是,如果我更改选择 SelectOneMenu中的画廊是空的(什么都没有显示,组件选择"面板本身是空的.)

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).

通过AJAX请求进行的更新有效.组件列表在更新时被检索,并根据需要请求预览和名称.但是,为更新的图库生成的HTML代码包含很少的行,比最初加载图库时要少,请参见此处:

The updating through the AJAX request works. 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:

<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).

我已经尝试过更新完整的表格,而不只是更新图库:相同的结果.我试图将画廊移出表格本身:同样的结果.我尝试在浏览器控制台中使用Javascript更新,就像在此处 , 什么都没发生.

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.

有人可以解决这个问题吗?

Does someone have a solution to this problem?

更新:我检查了服务器响应,该响应在应更新图库时得到发送.它包含与初始响应(当画廊工作时)完全相同的代码,因此JSF在呈现响应时一定有问题.但是对于如何处理这个问题仍然一无所知.

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. But still no clue on how to handle this.

编辑:一般情况:不应更新表单,而应更新完整的面板.

general thing: the form should not be updated, but the complete panel.

关于, 雪橇

推荐答案

我发现该问题已报告此处.

然后的临时解决方案是如下修改containerSelectionForm中的ajax请求:

The temporary solution then is to modify the ajax request in the containerSelectionForm as follows:

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

PrimeFaces.cw()的调用中,请确保已在对象中包含panelWidth这样的Galleria参数,该对象已经包含id.

In the call of PrimeFaces.cw() be sure to include galleria parameters like panelWidth in the object, that already contains the id.

这篇关于SelectOneMenu更改时,PrimeFaces更新图库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆