gpt4 book ai didi

javascript - 无法使用 onclick 显示 primefaces 面板

转载 作者:行者123 更新时间:2023-11-30 12:18:00 34 4
gpt4 key购买 nike

我试图显示一个带有 widgetVaronclick 的 p:panel,但它只显示了一瞬间。然后它又躲起来了。当它再次隐藏时,我在浏览器开发控制台中收到以下错误消息:

Uncaught TypeError: Cannot read property 'val' of undefined

错误也只会出现一瞬间。

这是我的 .xhtml 页面:

<?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:p="http://primefaces.org/ui">

<h:head>
<h:outputStylesheet library="css" name="style.css" />
<h:outputScript name="jquery/jquery.js" library="primefaces"/>
</h:head>

<h:body>
<h:form>
<p:commandButton value="testbutton" ajax="false" onclick="PF('panelwv').show();" />
<p:panel widgetVar="panelwv" visible="false" toggleable="true">
<h:outputText value="Test" />
</p:panel>
</h:form>
</h:body>
</html>

我使用的是 Primefaces 5.2。

最佳答案

p:commandButton 上有 ajax="false" 而没有指定 actionactionListener引用 bean 的属性会导致此问题。看起来您不需要或不想在服务器上调用任何操作,只需执行一些 javascript。在这种情况下,将 type="button" 添加到 p:commandButton

另见:

关于javascript - 无法使用 onclick 显示 primefaces 面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31874641/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com