CodeMirror enhancement

Community Driven Extensions Project
Post Reply
User avatar
planetsizebrain
Posts: 7
Joined: 08 Mar 2012, 17:21

08 Mar 2012, 17:24

I really like the CodeMirror component, but I'm missing one piece of functionality. I'd like to have a dynamic code suggestion system that uses a backing bean method to request a list of suggestions based on the current editor position. That way I could use the new Java Compiler API to provide Java code completion. I had a quick look at the component code, but can not see a way how I can link the Javascript event for code completion, CTRL+Space, to a backing bean method. Any ideas?

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

08 Mar 2012, 17:39

Currently is not possible.
You could create an feature request but i don't know if i have much free time in near future.
It would be cool if you could try it yourself and provide an patch.
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

User avatar
planetsizebrain
Posts: 7
Joined: 08 Mar 2012, 17:21

08 Mar 2012, 17:49

I'm going to try to hack it together in the following days and have found a few articles/post that could help me, but as I haven't created custom AJAX JSF2.0 components yet and AJAX/Javascript isn't my strong suit, I don't know how far I'll get.Any pointers to information about how to connect a Javascript call to a backing bean call and have the result of the backing bean method passed back to the client are always welcome.

I'll keep you posted.

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

08 Mar 2012, 17:50

Check out PrimeFaces Autocomplete. It should send the data via JSON the client - this could be reused for the CodeMirror.
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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

09 Mar 2012, 14:17

See PrimeFaces Ajax APIs in user's guide.

Adding sth like this to code mirror is not trivial btw, you need to send the data to codemirror component, then codemirror realizes it is a suggest request, calls sth like suggestListener, returns some markup, then you need to parse the response, get that markup, position an overlay and display it.

That's why we love PrimeFaces components, handles all this hard work for you :)

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

10 Mar 2012, 11:36

Yep, you're right Cagatay :)

I will add this in the future, but it would be cool if someone could do a part of this work :)
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

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

11 Mar 2012, 01:14

I'm currently working on it. It will be shipped with 0.4 if no further problems will occur.
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

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

11 Mar 2012, 16:40

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

16 Jun 2012, 17:48

I also implemented something similar for p:inputTextarea;

http://www.primefaces.org/showcase-labs ... xtarea.jsf

It completes while you type after 4 characters.

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests