2015-02-06 61 views
0

我试图使用<p:overlayPanel>作为小部件,如PrimeFaces展示示例(http://www.primefaces.org/showcase/ui/overlay/overlayPanel.xhtml)中所述。PrimeFaces OverlayPanel导致JavaScript错误“TypeError:f未定义”

我建立一个简单的应用程序,但在页加载它直接导致了JavaScript错误TypeError: f is undefined在第3栏,行1457中的“/javax.faces.resource/primefaces.js.xhtml?ln=primefaces & V = 5.1”

的XHTML体的代码是:

<h:form id="form"> 

    <p:commandButton update=":form:infoPanel" oncomplete="PF('testOverlayPanel').show('#{component.clientId}')" value="Test"/> 

    <p:overlayPanel widgetVar="testOverlayPanel" dismissable="false" showCloseIcon="true"> 
     <p:outputPanel id="infoPanel" style="text-align:center;"> 
      Hello OverlayPanel! 
     </p:outputPanel> 
    </p:overlayPanel> 

</h:form> 

当我删除了overlayPanel时,JavaScript错误消失。

当我按命令按钮,另外两个JavaScript错误出现:

  1. NetworkError:403禁止 - https://localhost:8443/test/index.xhtml
  2. 类型错误:PF(...)是未定义

我使用PrimeFaces 5.1和JSF 2.2.8

+0

你有h:头,h:身体等吗? – 2015-02-06 15:07:44

+0

@Jaqen:很可能,否则'primefaces.js'不会首先加载。 – BalusC 2015-02-06 15:12:42

+0

也想过,但谁知道:-) – 2015-02-06 15:14:03

回答

1

你不是在展示中使用它;-)。

<p:commandButton update=":form:infoPanel" 
    oncomplete="PF('testOverlayPanel').show('#{component.clientId}')" 
    value="Test"/> 

是供在数据表中使用(可以在展示中看到)。通常情况下,你只需要做一个

<p:commandButton update=":form:infoPanel" 
    oncomplete="PF('testOverlayPanel').show()" value="Test"/> 

但是,如果overlayPanel被“绑定”到特定的按钮,你还可以添加“为”在overlayPanel属性,如果你把一个id上的按钮类似

<p:commandButton id="imageBtn" value="Basic" type="button" /> 
<p:overlayPanel id="imagePanel" for="imageBtn" hideEffect="fade"> 
    <p:graphicImage name="/demo/images/nature/nature1.jpg" width="300" /> 
</p:overlayPanel> 

(不知道后者如何去使用Ajax调用)

+0

是的,目标是在数据专家中使用它,我也尝试过,但失败了。你确定这只是一个数据表? – philsner 2015-02-09 08:36:29

+0

它至少是一个数据表,而不是你如何在上面使用它。如果它也适用于数据专家,我不知道。从来没有尝试过,没有时间去尝试未来的日子 – Kukeltje 2015-02-09 08:54:53

+0

看起来,datalist只适用于''。感谢您的提示! – philsner 2015-02-09 16:52:08

1

I am using PrimeFaces 5.1 with JSF 2.2.8

在Primefaces 5.1版,如果你让号码:覆盖无为= “imageBtn”属性,错误的是显示浏览器的控制台上:

遗漏的类型错误:未定义

的修补程序(实际上是重叠重构)无法读取属性“长”已经COMMITED 11月14日,2014年,作为你可以看到下面:

https://code.google.com/p/primefaces/source/detail?r=12016

OverlayPanel除非你指定“为”属性,那就是不正常运行,我们指定的方式上Primefaces 5.1版本将无法正常工作数据表。

可能会在版本5.1.3和之后的工作。见https://code.google.com/p/primefaces/issues/detail?id=7615

0

我认为@LeonardoHAlmeida发布了正确的答案。 我找到了一个解决方法来避免这个错误。我刚刚创建了一个“假”按钮,只是为了能够在overlayPanel设定目标的“for”属性

<p:commandButton id="fakeButton" style="display: none"></p:commandButton> 

所以我覆盖的样子:

<p:overlayPanel widgetVar="wOverlay" appendToBody="true" for="fakeButton"> 
    <p:outputPanel id="display"> 
     ... 
    </p:outputPanel> 
</p:overlayPanel> 

而在我的DataTable中的按钮是:

<p:commandButton update=":form:display" oncomplete="PF('wOverlay').show('#{component.clientId}')" icon="ui-icon-search"> 
相关问题