2016-05-30 86 views
2

我想在我的JSF應用程序中使用primefaces-extensions ckEditor,如here所述。我加入了依賴我pom.xmlPrimefaces擴展ckeditor - 缺少工具欄

<dependency> 
    <groupId>org.primefaces.extensions</groupId> 
    <artifactId>primefaces-extensions</artifactId> 
    <version>4.0.0</version> 
</dependency> 

這是我的看法是如何的樣子:

<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> 

這是控制器(託管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 
} 

不幸的是,我可以」您可以看到一個工具欄,但只是一個文本輸入區域,如下圖所示:

Missing toolbar in ckEditor

UPDATE

有一個在我的控制檯JavaScript錯誤:

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) 

什麼會導致這個問題?我錯過了什麼嗎?

+1

你可以在控制檯中看到任何JavaScript錯誤? – tak3shi

+0

@ tak3shi:是的!對不起,我應該在發帖之前先做。但我仍然不知道,爲什麼會發生。你能幫我嗎?更新了我的帖子。 – John

+0

另一個提示可以在你的服務器日誌中找到:'無法從庫中找到或提供資源ckeditor/ckeditor.js,primefaces-extensions.' –

回答

2

添加以下依賴:

<dependency> 
    <groupId>org.primefaces.extensions</groupId> 
    <artifactId>resources-ckeditor</artifactId> 
    <version>4.0.0</version> 
</dependency> 
+0

非常感謝tak3shi!我錯過了這一點。 – John

+0

爲什麼哦爲什麼這不是展示中的第一行!?對於6.0.0,這也是必需的。 –