1. #1
    Sencha User
    Join Date
    Jun 2013
    Location
    Stockholm, Sweden
    Posts
    7
    Vote Rating
    0
    henkaa is on a distinguished road

      0  

    Default Javascript framwork and GXT 3.0.x

    Javascript framwork and GXT 3.0.x


    Hi.
    My goal is to create a component or widget that display a map (a map not made by google). The map api consists of some javascripts (including jquery) and other resources in a directory structure. (an example of the structure is displayed below)

    mywebroot
    |- mapapi
    | |- api-v1.2
    | | |- css
    | | |- js
    | | | |- i18n
    | | |- media
    | | | |- markers
    | | | | |- draw
    | | | | |- search
    | | | |- openlayers
    | | | |- popup

    Map requirements:
    * A div with a specified id that is passed to the constructor of the map in javascript code.
    * The directory structure and the root of it is passed to the constructor of the map in javascript code.

    In earlier attempts I have managed to get the map working in the following manner:
    * included the directory structure in the war directory of the project
    * Added the needed javascripts and css-entries in the main html-file.
    * Created a FormPanel() (this is code prior to gxt 3.0.x) and in that panel added a HTML() containing the div-structure that the map needs (a main div with a specified id and some button-divs)
    * Linkted the Java and javascript functions together with jni.
    * Override the LayoutContainer (containging the FormPanel) onLoad() and via it run the javascript that show the map.

    Now I want to make it a component so that it is separated from the application in a better way It will give me cleaner code and it is easier to reuse. But I do not know how to do this, so here are some questions:
    * Is it for starters possible at all to accomplish this?
    * Has anything similar been made before and are there examples to look at?
    * What class should I override do you think?
    * Can the directory structure (mapapi) be in the code (like for example the resources for the standard widgets) or must it be copied to war directory of each application that need the map?
    * Is there something else to think about when I need to connect via jni from javascript to a component object?

    Hope you can give some clarity on this matter. I would appreciate it alot.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,732
    Vote Rating
    90
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Many of your general questions should be solved by the GWT JSNI documentation:

    http://www.gwtproject.org/doc/latest...asicsJSNI.html

    Yes, it should certainly be possible - the Google Maps API for GWT must do almost exactly what you are describing, as do many other GWT libraries/widgets that wrap existing JS widgets. I would probably start with Component or Widget, and call setElement with an element to use as the root, then kick off the init process in JS to populate that element.

    Can the directory structure (mapapi) be in the code (like for example the resources for the standard widgets) or must it be copied to war directory of each application that need the map?
    If you are talking about the java package structure, then it can be whatever you want it to be that is reasonable. I'd probably put those JS/CSS/etc resources in the public/ directory and possibly reference them from within your module file.

    Look at another project which wraps a JS library, and how they call back and forth to make things work correctly, and read the JSNI document carefully - that should provide much of what you need to know to do this.

Thread Participants: 1

Tags for this Thread