我正在尝试使用Primefaces extensions 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>我完全不明白为什么这不起作用,看起来一切都是对的。
发布于 2017-05-20 16:20:27
我相信页面上必须至少有1个Primefaces组件,才能触发Primefaces将资源(js,css)注入头部。
试着把一些东西放进去,例如
<p:outputLabel style="display:none"/>并添加名称空间(xmlns:p="http://primefaces.org/ui")。
https://stackoverflow.com/questions/44073299
复制相似问题