When I use the ckeditor code in a xhtml file and tries to load this file using <ui:include> tag from another xhtml dynamically, ckeditor is not loading properly. It works when you load the page for the first time. After that it no longer works. It just loads the text area and getting a js error "Uncaught TypeError: Object [object Object] has no method 'ckeditor' ". Not sure about the exact reason. Looks like there is an issue with dynamic resource loading with ckeditor.
main.xhtml
Code: Select all
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions" >
<h:head>
</h:head>
<h:body>
<h:form>
<h:panelGrid id="panel">
<ui:include src="#{ckeditorBean.file}"></ui:include>
</h:panelGrid>
<p:commandButton value="Update" partialSubmit="true" update="panel"></p:commandButton>
</h:form>
</h:body>
</html>
Code: Select all
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions" >
<h:head>
</h:head>
<h:body>
First editor
<pe:ckEditor></pe:ckEditor>
</h:body>
</html>
Code: Select all
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:pe="http://primefaces.org/ui/extensions" >
<h:head>
</h:head>
<h:body>
Second editor
<pe:ckEditor></pe:ckEditor>
</h:body>
</html>
Code: Select all
@ManagedBean
@SessionScoped
public class CkeditorBean {
private boolean include1 = true;
public String getFile() {
String file = null;
if (include1) {
file = "include2.xhtml";
} else {
file = "include1.xhtml";
}
include1 = !include1;
return file;
}
}