Dynamic loading of ckeditor is not working

Community Driven Extensions Project
Post Reply
satyakishor.m
Posts: 10
Joined: 30 Oct 2012, 16:26

31 Oct 2012, 15:50

Hi

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>
include1.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>
	First editor
	<pe:ckEditor></pe:ckEditor>
</h:body>
</html>
include2.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>
	Second editor
	<pe:ckEditor></pe:ckEditor>
</h:body>
</html>
Managed Bean

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

}
Any help is appreciated.
Primefaces 3.4.1 | Mojarra 2.1.7 | Tomcat 7.0.27

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

31 Oct 2012, 15:54

No idea at the moment.
Please create a issue.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

Jodido
Posts: 5
Joined: 29 Sep 2010, 16:46

04 Dec 2012, 14:16

I hope I found the bug in primefaces-extensions.js
CKEDITOR_GETURL function seems to destroy the URLs, I debugged the code and found this urls like:
http://localhost:8080/javax.faces.resou ... s/paste.js

As you can see there is .xhtml?ln=primefaces-extensions.... inside the resource whats obviously wrong (this url was catched before the Primefaces extension process the url).

What I have done to remove this bug is:
I modified the code, before any changes to URL I made a check if the resource ends with '/'. If this case is matched I return this value without any changes.

The code looks like

Code: Select all

CKEDITOR_GETURL = function(resource) {
    var facesResource;
    //do not resolve
    var index=resource.lastIndexOf('/');
    if (resource.length-1 === index){
        return resource;
    }
    if (resource.indexOf('?resolve=false') !== -1) {
        facesResource = resource.replace('?resolve=false', '');
    } else {
     .....
I dont see this bug anymore

tandraschko
PrimeFaces Core Developer
Posts: 3979
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

04 Dec 2012, 14:23

My code is working fine and the bug above is already fixed in trunk.
Also there was a bug with .jsf mapping which is also fixed with 0.6.1 or 0.6.0. Maybe you should just upgrade.
Thomas Andraschko

PrimeFaces | PrimeFaces Extensions

Apache Member | OpenWebBeans, DeltaSpike, MyFaces, BVal, TomEE

Sponsor me: https://github.com/sponsors/tandraschko
Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

satyakishor.m
Posts: 10
Joined: 30 Oct 2012, 16:26

04 Dec 2012, 15:33

Thanks for fixing the issue.
Primefaces 3.4.1 | Mojarra 2.1.7 | Tomcat 7.0.27

Jodido
Posts: 5
Joined: 29 Sep 2010, 16:46

04 Dec 2012, 17:17

Good to know,
but I wont upgrade versions, because we are about to finish project. In this phase could be really painfull upgrade primefaces, primefaces-extensions.

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests