java - Primefaces 对话框将标题和内容显示为网页中的文本

标签 java primefaces

我是 Primefaces 新手,目前使用 primefaces 6.0,我正在尝试运行 primefaces 官方网站上的在线示例。

该示例演示了对话框的使用,我按照在示例中看到的方式进行操作,但是我观察到页面显示对话框标签标题属性的值,后跟对话框的内容作为文本

我希望有人告诉我我做错了什么,请参阅我的 View 中的以下代码和结果页面的屏幕截图

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

    <h:panelGrid columns="1" cellpadding="5">

    <p:commandButton value="Basic" type="button" onclick="PF('dlg1').show();" 
    />

     <p:commandButton value="Modal" type="button" onclick="PF('dlg2').show();" />

    <p:commandButton value="Effects" type="button" onclick="PF('dlg3').show();" /> 

     </h:panelGrid>


    <p:dialog header="Basic Dialog" widgetVar="dlg1" minHeight="40">
    <h:outputText value="Resistance to PrimeFaces is futile!" />
    </p:dialog>


     <p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" 
     height="100">
    <h:outputText value="This is a Modal Dialog." />
    </p:dialog> 


    <p:dialog header="Effects" widgetVar="dlg3" showEffect="explode" 
     hideEffect="bounce" height="100">
    <h:outputText value="This dialog has nice effects." />
    </p:dialog>
    </html>

enter image description here

最佳答案

您的页面中必须有 h:head 标记。

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>

http://primefaces.org/faq.html

关于java - Primefaces 对话框将标题和内容显示为网页中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55809490/

相关文章:

ajax - JSF PrimeFaces 进度条问题

java - 字符串生成器不使用字符串池中的字符串文字。为什么?

java - 当使用扫描仪输入值到数组时找不到最小的数字

java - Glassfish - java.lang.NoClassDefFoundError : org/primefaces/model/UploadedFile

css - 如何更改背景颜色工具提示 primefaces 扩展名?

ajax - 如果设置了其他 SelectOneMenu 的值,则更新 SelectOneMenu(未触发事件)

java - JSF + hibernate : Collection is not associated with any session

java - 将增强型 for 循环转换为常规 for 循环

c# - 正则表达式 - 增量替换

java - 使用语言解析编辑 XML 节点 - Java