【问题标题】:Primefaces CKeditor won't renderPrimefaces CKeditor 不会渲染
【发布时间】:2017-10-19 18:37:13
【问题描述】:

我正在尝试使用 Primefaces 扩展 CKeditor,但无法使其正常工作。关于 SO 的所有类似问题都是由于不包括 resource-ckeditor 引起的,我已经这样做了。我在浏览器中收到一个 javascript 错误,这可能是相关的。以下代码仅呈现大小可调整的文本区域框。

<?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://xmlns.jcp.org/jsf/html"
      xmlns:pe="http://primefaces.org/ui/extensions"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>Facelet Title</title>
    </h:head>
    <f:view>
    <h:body>
        <h:form>
        <pe:ckEditor id="editor" value="Test">  
        </pe:ckEditor>
        </h:form>
    </h:body>
    </f:view>
</html>

这是我的 POM

<dependency>
            <groupId>org.primefaces</groupId>
            <artifactId>primefaces</artifactId>
            <version>6.1</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces.extensions</groupId>
            <artifactId>primefaces-extensions</artifactId>
            <version>6.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.primefaces.extensions</groupId>
            <artifactId>resources-ckeditor</artifactId>
            <version>6.1.0</version>
        </dependency>

这是我在浏览器中遇到的错误

test.xhtml:8 Uncaught ReferenceError: $ is not defined

这是输出到浏览器的相关HTML代码

<h:inputText></h:inputText><textarea id="editor" name="editor">test</textarea><script id="editor_s" type="text/javascript">$(function(){PrimeFaces.cw("ExtCKEditor","widget_editor",{id:"editor",height:"200px",width:"600px",readOnly:false,advancedContentFilter:true});});</script>

我完全不明白为什么这不起作用,似乎一切都是正确的。

【问题讨论】:

  • $ is not defined 表示您可能忘记导入合适的 jQuery 库。
  • @Tiny,谢谢 - 这一定意味着 JSF 或 Primefaces 在某个地方被破坏了,因为我认为这些框架应该处理这个问题。或者 Maven 没有下载所需的依赖项?

标签: jsf primefaces ckeditor primefaces-extensions


【解决方案1】:

我认为页面上必须至少有 1 个 Primefaces 组件才能触发 Primefaces 将资源(js、css)注入头部。

试着在里面放点东西,例如

<p:outputLabel style="display:none"/>

并添加命名空间 (xmlns:p="http://primefaces.org/ui")。

【讨论】:

  • 感谢您的回复,绝对值得一试,但没有爱
猜你喜欢
  • 1970-01-01
  • 2012-07-04
  • 2017-08-10
  • 2017-01-01
  • 2011-06-12
  • 2020-03-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多