monacotoni
monacotoni

Reputation: 606

How can I reuse the file chooser of ckeditor grails plugin?

I'm using the ckeditor plugin for grails (:ckeditor:3.6.2.2) and I'd like to reuse the File Chooser used to select images inside the rich text editor. I'd like to use it in a form for selecting images.

The plugin documentation makes me assume this is possible: "If you just need the link to the file browser there is a fileBrowserLink tag:

<a href="${ckeditor:fileBrowserLink(type:'Image', userSpace:'userone')}">Open file browser</a>

If you want get back the path of the selected item in the file browser simply define a javascript function called ckeditorFileBrowserItemSelected in the page containing the opening link.

<script type="text/javascript" charset="utf-8">
function ckeditorFileBrowserItemSelected(path) {
    // do whatever you want with path
    alert(path);
}
</script>"

http://stefanogualdi.github.com/grails-ckeditor/docs/ref/Tags/fileBrowser.html

Unfortunately I'm not getting it to work. If I use the above approach to create a link, I'm getting an exception:

errors.GrailsExceptionResolver MissingMethodException occurred when processing request: [GET] /Admin/courseTemplate/create
No signature of method: Users_antonepple_NetBeansProjects_Eppleton_Relaunch_Admin_grails_app_views_courseTemplate_create_gsp.fileBrowserLink() is applicable for argument types: (java.util.LinkedHashMap) values: [[type:Image, userSpace:userone]].

I also tried using the fileBrowser Tag like this:

               <ckeditor:fileBrowser type="Image" userSpace="userone">Open file browser</ckeditor:fileBrowser>

As a result the File Manager opens instead of the FileChooser I'm looking for. The File manager doesn't allow to select an image.

What am I doing wrong, and what can I do instead to reuse the File Chooser?

Upvotes: 0

Views: 649

Answers (1)

monacotoni
monacotoni

Reputation: 606

OK, I figured out how to do it. The documentation has a typo instead of this:

<a href="${ckeditor:fileBrowserLink(type:'Image', userSpace:'userone')}">Open file browser</a>

it should be:

<a href="${ckeditor.fileBrowserLink(type:'Image', userSpace:'userone')}">Open file browser</a>

An advanced grails user would probably have spotted this earlier :-). The second problem was, that there was no way to select an image in the file manager. But as soon as the FileManager is opened in a separate window it has an additional action in a files context menu allowing me to choose an image. So I just need to:

<a href="${ckeditor.fileBrowserLink(type:'Image', userSpace:'userone')}"  target="_blank">Open file browser</a>

...or open fileBrowser in a dialog and this action becomes available...

Upvotes: 0

Related Questions