emnadridi / gmaps4jsf

Automatically exported from code.google.com/p/gmaps4jsf
0 stars 0 forks source link

marker "onclick" server-side event #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

Im tring to trigger a server-side event from a mouse-click on a marker:
I thought I could use JBoss' a4j library to push the event to the server.
Unfortunately it does not work...
Any suggestions?

<h:form id="mapForm">
  <m:map width="100%" height="500px" address="#{addressBean.address}"
    zoom="14">
    <m:marker address="#{mapBean.currentAddress.string}">
      <a4j:support event="onclick" action="#{mapBean.doo}" />
    </m:marker>
  </m:map>
>/h:form>

Original issue reported on code.google.com by alex.ker...@gmail.com on 6 Apr 2010 at 2:22

GoogleCodeExporter commented 9 years ago
The click event is not supported yet on the GMaps4JSF marker. We will support 
this
feature on next versions.

Original comment by Hazem.sa...@gmail.com on 14 Apr 2010 at 5:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Great to hear that!
For now, is there any other way to forward an event from within the map / 
marker to 
the server?
Many thanks for this great framework!

Original comment by alex.ker...@gmail.com on 15 Apr 2010 at 2:47

GoogleCodeExporter commented 9 years ago
Yes,

Check this example:
http://www.mashups4jsf.com/gmaps4jsf-examples/pages/markersServerSideEvents.jsf

Original comment by Hazem.sa...@gmail.com on 18 Apr 2010 at 1:14

GoogleCodeExporter commented 9 years ago
In this example I actually have to change position of the marker, meaning 
dragging it.
I don't want to move it, I just want to tell the server that one marker has 
been 
selected by the user, in oder to show further information on the page 
concerning this 
marker.

Original comment by alex.ker...@gmail.com on 18 Apr 2010 at 4:36

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago

Original comment by Hazem.sa...@gmail.com on 3 Dec 2010 at 6:23

GoogleCodeExporter commented 9 years ago
I need this funcionality too, I tried to do with a javascript function:

function markerSelected(idMarker) {
   return function(latlng) {
      document.getElementById('forma:hiddenInput').value = idMarker;
      document.getElementById('forma:hiddenBtn').click();
   };
}

These are the Marker code
<ui:repeat value="#{papelerasBean.papeleras}" var="papelera">
   <m:marker latitude="#{papelera.latitude}" longitude="#{papelera.longitude}"   
      jsVariable="pap#{papelera.id}">
      <m:icon shadowImageURL="http://www.google.com/mapfiles/shadow50.png"
         imageURL="#{papelera.icon}" />
      <m:htmlInformationWindow htmlText="#{papelera.direccion}" />
      <m:eventListener eventName="click" jsFunction="markerSelected('#
         {papelera.id}')"/>
   </m:marker>
</ui:repeat>

And this are the jsf components:

<ice:inputHidden id="hiddenInput" 
value="#{papelerasBean.idMarkerSelected}"></ice:inputHidden>
<ice:commandButton id="hiddenBtn" 
actionListener="#{papelerasBean.muestraDetalle}" style="display:none" 
partialSubmit="true"/> 

The javascript function tries to generate the click event on the commandButton, 
and the commandButton has an ActionListener in order to show more information 
abpout this Marker.

My problem with this approach is that Im getting an error 500, and i dont know 
what is the cause for it:

Estado HTTP 500 -

type Informe de Excepci�n

mensaje

descripci�n El servidor encontr� un error interno () que hizo que no 
pudiera rellenar este requerimiento.

excepci�n

java.lang.ArrayIndexOutOfBoundsException: 1
    com.googlecode.gmaps4jsf.component.map.MapRenderer.decode(MapRenderer.java:87)
    javax.faces.component.UIComponentBase.decode(UIComponentBase.java:789)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1031)
    javax.faces.component.UIForm.processDecodes(UIForm.java:209)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
    javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
    javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:540)
    com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
    com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:17)
    com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:94)
    com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:54)
    com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:26)
    com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
    com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160)
    com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:38)
    com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:19)
    com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
    com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:55)
    com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:19)
    com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
    com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:91)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)

Could yout help on this please?

Original comment by iban...@gmail.com on 21 Jan 2011 at 6:45

GoogleCodeExporter commented 9 years ago
Is the 'click' event supported in the current version?

Original comment by mic...@gmail.com on 20 Apr 2013 at 2:12

GoogleCodeExporter commented 9 years ago
You are lucky. it is fixed now in the latest GMaps4JASF 3.0.1 snapshot, now 
Ajaxified marker onclick actions can work as follows:
<m:marker id="marker1" latitude="30.01" longitude="31.14" 
          jsVariable="marker1" draggable="false">

          <m:icon imageURL="http://www.google.com/mapfiles/markerA.png"/>                                        
          <f:ajax event="click" listener="#{map.processClickForMarker}" render="firstMarkerStatus"/>
</m:marker>

I attached below the latest snapshot of GMaps4JSF 3.0.1.

Original comment by Hazem.sa...@gmail.com on 20 Apr 2013 at 5:42

Attachments:

GoogleCodeExporter commented 9 years ago
Well, that truly is a professional customer service :). Thanks a lot.

Original comment by mic...@gmail.com on 20 Apr 2013 at 6:46

GoogleCodeExporter commented 9 years ago
U are welcome. Please do me a favor and let me know the project name, company 
name, URL (if applicable) of the project that uses GMaps4JSF to add to the 
projects' wiki.

Original comment by Hazem.sa...@gmail.com on 20 Apr 2013 at 7:17

GoogleCodeExporter commented 9 years ago
It's just a personal project for tracking my own travels. 

Original comment by mic...@gmail.com on 20 Apr 2013 at 8:07

GoogleCodeExporter commented 9 years ago
There is another difference between the valueChangeListener 
(http://www.mashups4jsf.com/gmaps4jsf-examples/pages/markersServerSideEvents.jsp
.source) and <f:ajax event="click" listener="#{map.processClickForMarker}", 
which puzzles me. In the first case I easily get marker attributes into the 
backing with a ValueChangeEvent object. In the second case I have only a 
changeListener() without possibility to transfer a parameter (cf. 
http://stackoverflow.com/questions/16124933/hselectmanychexkboxs-fajax-event-cli
ck-listener-doesnt-fire-and-gives-an).
My requirement is the following: I get a marker from an address (cf. 
http://www.mashups4jsf.com/gmaps4jsf-examples/pages/getMyLocation.jsf). By 
click to the displayed marker I want to get latitude and longitude of it 
transferred to my bean. With attribute binding latitude and longitude to the 
marker it does not work - I do not even get the map displayed. Probably there 
is fatal conflict between the address attribute and the coordinates, which are 
null in the start situation:

                <m:marker draggable="true"
                    latitude="#{mapAddressSiteBacking.latitude}"
                    longitude="#{mapAddressSiteBacking.longitude}">
                    <m:htmlInformationWindow
                        htmlText="#{mapAddressSiteBacking.getGoogleAddressString()}" />
                    <m:eventListener eventName="dragend" jsFunction="markerDragHandler" />
                    <f:ajax event="click" listener="#{mapAddressSiteBacking.read()}"
                        render="#{mapAddressSiteBacking.renderForms}" />
                </m:marker>

Does anyone have an idea how to achieve that. Thanks in advance

Chris

Original comment by christop...@jki.bund.de on 3 Jul 2013 at 10:06