Hi,
First I'm really impressed by FCK! excelent job!
I'm working to integrate FCK into a Visual Web Netbeans project (=JSF+Woodstock)
I know I could also use ICEFace as this already includes FCK, however ICE is not yet fully integrated as Woodstock is.
Ok here are my options, and I hope some one could give me some improvement to do this correct.
I have two implementations working (hope this helps others as well integrating FCKeditor)
1. I wrote a wrapper in the backBean of the JSF page.
In the backbean I added the following code:
Home.java:
public String getFckEditorHTML() { HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); FCKeditor editor = new FCKeditor(request, "editorDefault"); return editor.createHtml(); }
Now in my Visual Web editor of Netbeans I simple add a Static text field, and bind that with the Page.fckEditorHTML (the function created above)
This works ok. The editor is available, however (as prob. I lack some knowledge here) The only way to get the text is to lowlevel pull it out from the "request like this:
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); String myPostedData = request.getParameter("editorDefault");
Advantage is: It's quick & dirty.
Problem: Data is lost as soon as a partial post is don on the page like a pulldown is changed or other..
The code actaly generates a hidden text field with an id in the output. If only I could use a JSF/Woodstock hidden text field for that I probaly would be able to bind to that hidden text field to read/set the data into the FCKeditor...
Question: How Can I keep the data that is in the editor when I do a partial post on the page? What do I need to do?
Option 2:
I use the taglib:
<jsp:root version="2.1" [b]xmlns:FCK="http://java.fckeditor.net"[/b] xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:webuijsf="http://www.sun.com/webui/webuijsf"> . . . . <FCK:editor instanceName="editorDefault"></FCK:editor>
Problem here again.. The data is not kept during partial posts, and the editor is not accessible from any of the Beans..
Also here, I need to pull the data out rather low level:
HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest(); String myPostedData = request.getParameter("editorDefault");
Any hints how I could do this in a more clean way so that any partial post will keep the data in the editor and not clean it out again?
Many thanks in advance!
Wessel
Re: Best practise: FCKeditor in JSF/Woodstock Netbeans
You could use some JS to copy the textarea content to another hidden field which is actually bound to your bean.
I don't think that there is a clean way since the editor is a client-side component and JSF is a server-side issue.
BUT I am not skilled in JSF, this can maybe solvable anyway. Some other folks were struggling already with JSF and the editor. You may search the forums for.
Re: Best practise: FCKeditor in JSF/Woodstock Netbeans
That is an interesting idea to copy it client side into a hidden field that operates within the JSF context. The way I currently solved it is similar only I do the copying on the server side. I do use the wrapper combined with the FCKeditorConfig class , it gives me full control how to launch the editor. and I use a JSF hidden field to store the content. This hidden field is then preserved during partial posts and Ajax interaction with the page.
I've searched the forums and some notes are there, also a fckeditor-faces jar.
Wessel
Re: Best practise: FCKeditor in JSF/Woodstock Netbeans
There is some other project which claims to integrate the editor into JSF. I have scanned the code and it's crap (in my opinion). Unstructured and limited.
Besides that I would like to add JSF support, make it JSF-aware somehow but I have no idea where it start with JSF since there are zillions of implementations and I don't know if it would make sense to stick to Sun's RI. Another issue is the spare time I have. Since I am full time student and work part-time, I have very little time to start with JSF from the scratch.
If you can point me in the right direction, I would provide this feature for version 2.6.
Mike