0

我在popupPanel 中有一个pickList。如果我打开 popupPanel,它会出现在窗口的中间。如果我关闭并重新打开它,它看起来会向左和底部移动。只有当我在 popupPanel 中有 pickList 时才会发生这种情况。如果我删除它,一切都会按预期工作。

下面我有一个重现问题的片段。我使用的是 RichFaces 4.1,该问题在 IE、Chrome 和 Firefox 上可重现(其他未测试)。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html" 
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:rich="http://richfaces.org/rich" 
      xmlns:fn="http://java.sun.com/jsp/jstl/functions">

    <h:head></h:head>
    <h:body>
        <rich:popupPanel domElementAttachment="parent" id="popup" autosized="true" modal="true">
            <h:commandButton value="Close" onclick="#{rich:component('popup')}.hide();" />
            <rich:pickList>
                <f:selectItems value="#{fn:split('Test,TestTest,TestTestTest', ',')}" />
            </rich:pickList>
        </rich:popupPanel>
        <h:commandButton value="Panel" onclick="#{rich:component('popup')}.show();" />
    </h:body>
</html>
4

2 回答 2

2

在不理解为什么的情况下,我可以通过更改domElementAttachment="parent"domElementAttachment="body". 如果弹出窗口是在表单内定义的,body则可以替换为form.

我真的不知道为什么会这样,并且会对解释非常感兴趣。

于 2012-05-24T11:06:37.973 回答
1

原因是Richfaces 错误 11736。已知的解决方法是:

  1. Sandros:将 domElementAttachment 从父级更改为主体。
  2. 在显示面板之前调用 Javascript 函数:

    onbeforeshow="fixPositioning('#{rich:clientId('popupPanelId')}');"
    

    函数定义如下:

    function fixPositioning(panelId) {
        var popupPanel = document.getElementById(panelId);
        if (popupPanel) {
            popupPanel.style.visibility = "hidden";
            popupPanel.style.display = "block";
        }
    }
    

    那里描述了这个解决方案

于 2014-03-27T08:24:07.307 回答