ICEfaces
  1. ICEfaces
  2. ICE-10464

ace:gMap - Add an actionListener when a gMapEvent is triggered

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: EE-3.3.0.GA_P02, 4.0
    • Fix Version/s: EE-4.0.0.GA, EE-3.3.0.GA_P03, 4.1
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      All

      Description

      Feature Request: Add a way to notify the server when a gMapEvent is triggered.

      Note on this behavior from Art:

      Implement an actionListener on the ace:gMap component that would fire whenever a Google Maps event, registered via ace:gMapEvent, is triggered. The listener method would receive a special event object that would contain a reference to the gmap component object and a reference to the subcomponent that triggered the event, in this case a marker.

      In rough terms, it would work like this:

      <ace:gMap eventListener="#{bean.gMapEventListener}" .... >
              <ace:gMapMarker latitude="0" longitude="0">
                  <ace:gMapEvent eventType="click" scriptToUse="/* client-side code */"/>
              </ace:gMapMarker>
      </ace:gMap>

      public void gMapEventListener(GMapEvent event) {
          event.getGMap();
          event.getComponent();
          event.getType();
      }

      This way, it would be necessary to only write one listener method and it wouldn't be necessary to write additional javascript code to send the request to the server.

        Activity

        Hide
        Arturo Zambrano added a comment -

        r43999: added server-side listener to ace:gMapEvent in the 3.3 EE maintenance branch.

        The final approach changed from the original idea, to make it more convenient and usable. Instead or registering a single listener in the root ace:gMap component, the listener is registered in each individual ace:gMapEvent component. This way, it's not necessary to write code to identify which event component triggered the event.

        Things work this way now:

        <ace:gMap ... > 
                <ace:gMapMarker latitude="0" longitude="0"> 
                    <ace:gMapEvent eventType="click" scriptToUse="/* client-side code */" listener="#{bean.eventListener}" /> 
                </ace:gMapMarker> 
        </ace:gMap> 
        
        	public void eventListener(org.icefaces.ace.event.MapEvent event) {
        		System.out.println();
        		System.out.println("*** ace:gMapEvent listener triggered ***");
        		System.out.println("* ace:gMapEvent component : " + event.getComponent().getClientId());
        		System.out.println("* ace:gMap component : " + event.getGMap().getClientId());
        		System.out.println("* parent component : " + event.getParent().getClientId());
        	}
        

        The code above can be integrated into the /gMap/gMapEvent.jsf test page.

        Show
        Arturo Zambrano added a comment - r43999: added server-side listener to ace:gMapEvent in the 3.3 EE maintenance branch. The final approach changed from the original idea, to make it more convenient and usable. Instead or registering a single listener in the root ace:gMap component, the listener is registered in each individual ace:gMapEvent component. This way, it's not necessary to write code to identify which event component triggered the event. Things work this way now: <ace:gMap ... > <ace:gMapMarker latitude= "0" longitude= "0" > <ace:gMapEvent eventType= "click" scriptToUse= "/* client-side code */" listener= "#{bean.eventListener}" /> </ace:gMapMarker> </ace:gMap> public void eventListener(org.icefaces.ace.event.MapEvent event) { System .out.println(); System .out.println( "*** ace:gMapEvent listener triggered ***" ); System .out.println( "* ace:gMapEvent component : " + event.getComponent().getClientId()); System .out.println( "* ace:gMap component : " + event.getGMap().getClientId()); System .out.println( "* parent component : " + event.getParent().getClientId()); } The code above can be integrated into the /gMap/gMapEvent.jsf test page.
        Hide
        Arturo Zambrano added a comment -

        r44006: committed improvement to the 3.3 EE maintenance branch.

        Show
        Arturo Zambrano added a comment - r44006: committed improvement to the 3.3 EE maintenance branch.
        Hide
        Liana Munroe added a comment -

        Tested with ICEfaces 4 trunk and ee- 3.3.0 maintenance branch r44009. The listener is verified to work but the is a js console error seen in all browsers when activating the listener.
        FF: TypeError: a is undefined
        IE 11: SCRIPT5007: Unable to get property 'addEventListener' of undefined or null reference
        Chrome 39: Uncaught TypeError: Cannot read property 'addEventListener' of undefinedmain.js:17 T.addDomListenergmap.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:8 google.maps.event.addDomListenergmap.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:40 ice.ace.gMap.addEventgmap.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:14 ice.ace.gMap.recreategmap.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:3 ice.ace.gMap.getGMapWrapperVM153:1 (anonymous function)jquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:69 mjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:69 q.addjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:74 d.fn.readyjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:64 d.fn.initjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:195 h.fn.initjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:17 d

        Show
        Liana Munroe added a comment - Tested with ICEfaces 4 trunk and ee- 3.3.0 maintenance branch r44009. The listener is verified to work but the is a js console error seen in all browsers when activating the listener. FF: TypeError: a is undefined IE 11: SCRIPT5007: Unable to get property 'addEventListener' of undefined or null reference Chrome 39: Uncaught TypeError: Cannot read property 'addEventListener' of undefinedmain.js:17 T.addDomListenergmap.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:8 google.maps.event.addDomListenergmap.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:40 ice.ace.gMap.addEventgmap.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:14 ice.ace.gMap.recreategmap.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:3 ice.ace.gMap.getGMapWrapperVM153:1 (anonymous function)jquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:69 mjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:69 q.addjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:74 d.fn.readyjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:64 d.fn.initjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:195 h.fn.initjquery.c.js.jsf?ln=icefaces.ace&v=4_1_0_150204:17 d
        Hide
        Liana Munroe added a comment - - edited
        Show
        Liana Munroe added a comment - - edited Listener functionality was added to /gMapEvent.jsf applications located at: http://dev.icesoft.com/svn/repo/qa/trunk/Regression-Icefaces4/Sparkle/Manual/gMap http://dev.icesoft.com/svn/repo/qa/trunk/Regression-Icefaces2/Sparkle/Manual/gMap
        Hide
        Arturo Zambrano added a comment -

        Committed fix to check if parent element exists before invoking Google Maps API, at revision 44017 to the 4.0 trunk and at revision 44018 to the 3.3 EE maintenance branch.

        The console error was caused precisely because the info window was no longer present when saving the map state in the client.

        Show
        Arturo Zambrano added a comment - Committed fix to check if parent element exists before invoking Google Maps API, at revision 44017 to the 4.0 trunk and at revision 44018 to the 3.3 EE maintenance branch. The console error was caused precisely because the info window was no longer present when saving the map state in the client.
        Hide
        Liana Munroe added a comment - - edited

        Verified ICEfaces 4 trunk, ee-3.3.0 maintenance branch r44022. Tomcat 7, IE 11, 10, 9, 8, FF 34, Chrome 40.
        Note* - when tested with IE 9 the listener did not respond the first time but did work on the 2nd or 3rd attempt. Could be a test machine issue.

        Show
        Liana Munroe added a comment - - edited Verified ICEfaces 4 trunk, ee-3.3.0 maintenance branch r44022. Tomcat 7, IE 11, 10, 9, 8, FF 34, Chrome 40. Note* - when tested with IE 9 the listener did not respond the first time but did work on the 2nd or 3rd attempt. Could be a test machine issue.

          People

          • Assignee:
            Arturo Zambrano
            Reporter:
            Arran Mccullough
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: