Jun 13, 2015

JSF2Leaf

JSF2Leaf is a JavaServer Faces component that allows a simpler way to insert maps in your webpage using just a tag, like any other JSF component. This is possible because JSF2Leaf wraps the Leaflet map library, using OpenStreetMap as map provider.

The library source code contains a built-in test page, that teach us how use it:

The library is simple and supports Markers, Layers, Polylines, Circles and Clusterization (for a lot of markers). Examples can be found on the Github project page. A simple Primefaces "contact us" form for example, can be seen below:

 


15 comments :

  1. Is it work only with java 8? when i included your library in my project I caught following exception:

    Caused by: java.lang.UnsupportedClassVersionError: com/jsf2leaf/component/MapAdvanced : Unsupported major.minor version 52.0"

    ReplyDelete
    Replies
    1. Hello, the .jar lib provided/compiled on the github page was generated with Java 8, so yes. But you can compile the lib yourself with any other Java version if needed, just use the sources.

      Delete
    2. Thank you, but packaging type it is "war" and when I executed mvn clean install I got jsf2leaf-.war

      Delete
    3. the lib generation is a manual process, you don't use the maven, you get some files and pack them with the java jar tool. But this is a generic Java question, not specific for my lib, so you can find help on internet!

      Delete
  2. Are there any events for marker such as draggable marker which can send updated lat-longs to the backing bean?

    ReplyDelete
  3. Hello, my library that is just a wrapper not, but the LeafLet library itself has, take a look:
    http://leafletjs.com/reference.html#map-events

    ReplyDelete
  4. I love this package for its simplicity. It would be great if draggable marker is also implemented with some kind of ajax functionality much like the Primefaces interface for Google maps p:gmap tag and send back updated coordinates to the backing bean. Could you possibly consider this enhancement and release an update?

    ReplyDelete
    Replies
    1. The lib purpose was just to create the map, but not do stuff later. Sorry, I don't pretend to touch it again, but feel free to change the code yourself !

      Delete
  5. Hello, i can explain how to generate the jar using eclise with java 7? Please?

    ReplyDelete
    Replies
    1. Hello Wilow, as you can see I work with a lot of things, so I don't remember well, but I checked my notes here and was used the following command:
      "jar cf jar-file input-file(s)"

      jar is a java tool, you will find it in the Java binaries folder (if it's not present in your system already). The tool get some files and pack them into a single .jar file. The files needed you can see in the actual .jar file on the github page. Hope this helps. Good luck!

      Delete
  6. hello...
    i am trying to use your lib (jsf2leaf) with primefaces with mapAdvanced tag.
    i tried you example that you provided in github but there were some problems in
    auto injected js's.
    the problems:
    on js console:
    Uncaught SyntaxError: Unexpected token ,
    and the line that gives this error is:
    var map_j_idt73 = L.map('j_idt73', {center: [,], dragging: , zoomControl: , zoom: });

    as you see non of the fields are not filled.

    i have initialized all those fields (and possible all of them) on the bean side and tried to return a Map. (as ia said above i also tried your example with all fields)

    btw:
    i have played with your pom.xml and make the jar available for local maven repo.

    seems like there is some kind of bug but could not figure out...

    any help (as owner of this jsf2leaf) will be good to me.

    thanks in advance.

    ReplyDelete
    Replies
    1. Hello, have you tried the tag v1.0 instead of master? because I have accepted a pull request from someone but without test it, due the lack of my Java environment.

      Also, are you using the java 8? if I remember well, I was using the primefaces 5.1 too, please try these things !

      Delete
    2. hi,
      i have tried tag 1.0 and master both.
      no luck. i got same error which the fields are not filled.

      and yes. oracle java 8 and pf 6.

      i can stop myself asking, this is great tool, why don't you keep this updated and push it to global mvn repo?

      thanks.

      Delete
  7. how can I use it in maven?
    com.jsf2leaf
    jsf2leaf
    a.b
    system
    ${basedir}/WEB-INF/lib/my.artifact.jar

    ReplyDelete
    Replies
    1. Hello Erick, the lib is not in the maven repository, so you need include manually in your project dependencies, include a .jar library in your project is a generic process, you can find information on internet. Thanks!

      Delete