问题
I am trying to use the primefaces-extensions ckEditor
in my JSF application, as described here. I added the dependency to my pom.xml
:
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>primefaces-extensions</artifactId>
<version>4.0.0</version>
</dependency>
This is how my view looks like:
<p:growl id="editorgrowl" showDetail="true" />
<pe:ckEditor id="editor" value="#{mbEditorController.content}"
toolbar="[['Cut','Copy','Paste','PasteText','PasteFromWord','-', 'SpellChecker', 'Scayt']]">
<p:ajax event="save"
listener="#{mbEditorController.saveListener}"
update="editorgrowl" />
</pe:ckEditor>
This is the controller (managed bean):
@ManagedBean(name = "mbEditorController")
@ViewScoped
public class EditorView implements Serializable {
private static final long serialVersionUID = 6822767317343704211L;
private String content;
private String secondContent;
public EditorView() {
content = "Type in your text here...";
secondContent = "This is a second editor";
}
public void saveListener() {
content = content.replaceAll("\\r|\\n", "");
final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Content",
content.length() > 150 ? content.substring(0, 100) : content);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public void secondSaveListener() {
secondContent = secondContent.replaceAll("\\r|\\n", "");
final FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Second Content",
secondContent.length() > 150 ? secondContent.substring(0, 100) : secondContent);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
// getters, setters
}
Unfortunately I can't see a toolbar, but just a text input area, as you can see in the following screenshot:
UPDATE
There is a javascript error in my console:
http://localhost:8080/MyApp/javax.faces.resource/ckeditor/ckeditor.js.xhtml?ln=primefaces-extensions&v=4.0.0 Failed to load resource: the server responded with a status of 404 (Not Found)
What could cause the problem? Am I missing something?
回答1:
Add the following dependency:
<dependency>
<groupId>org.primefaces.extensions</groupId>
<artifactId>resources-ckeditor</artifactId>
<version>4.0.0</version>
</dependency>
来源:https://stackoverflow.com/questions/37520069/primefaces-extensions-ckeditor-missing-toolbar