darshakshah1988 / gmaps4jsf

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

Not showing Map with ADFaces Form component and gmaps4jsf-1.1.4 #157

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
hi,
I am working with jdeveloper 11.1.1.4 and gmaps4jsf-1.1.4
This page JSF don't work:

?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
          xmlns:trh="http://myfaces.apache.org/trinidad/html"
          xmlns:gmaps4jsf="http://code.google.com/p/gmaps4jsf/">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <af:form id="f1">
        <af:decorativeBox id="db1">
          <f:facet name="center">
            <gmaps4jsf:map id="m1" latitude="36.717954" longitude="-4.421386"
                           partiallyTriggered="true" width="400px"
                           height="400px" jsVariable="map" zoom="14"
                           type="G_NORMAL_MAP"/>
          </f:facet>
          <f:facet name="top">
            <af:outputLabel value="Pruebas GMAPS4JSF" id="ol1"/>
          </f:facet>
        </af:decorativeBox>
      </af:form>
      <f:facet name="metaContainer">
        <trh:script 

source="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=AB
QIAAAAfWaHRSVm60PthsQlilBjFBRi

_j0U6kJrkFvY4-OX2XYmEAa76BQI1WTKk4FfNHLB_4TC2EnUuZOQpg"
                    id="scriptKeyGoogle"></trh:script>
      </f:facet>
    </af:document>
  </f:view>
</jsp:root>

----------- the error is:
java.lang.RuntimeException: cannot find a standard parent form for gmaps4jsf 
component
    at com.googlecode.gmaps4jsf.util.ComponentUtils.findParentForm(ComponentUtils.java:311)
    at com.googlecode.gmaps4jsf.component.map.MapRenderer.convertToJavascriptObject(MapRenderer.java:119)
    at com.googlecode.gmaps4jsf.component.map.MapRenderer.startEncodingMapWorld(MapRenderer.java:182)
....more

the proble is

    <af:form id="f1">
       ......
    </af:form>

when I replace it with this other

    <h:form id="f1">
      ......
    </h:form>

the code works and the map shows, but this form (h:form) don't allow stretch 
their children 

Is possible that maps work fine with af:form? i a bug?

The class java which reporte the error is 
com.googlecode.gmaps4jsf.util.ComponetUtils.java :

---------------------------

        /**
         * Traverses the component tree beginning from the given component instance, stops when finds the 

enclosing form
         *
         * @param context
         * @param component
         */
        public static UIComponent findParentForm(FacesContext context, UIComponent component) {
                UIComponent parent = component;

                while(parent != null && (!(parent instanceof UIForm))) {
                        parent = parent.getParent();
                }

        if (parent == null) {
            throw new RuntimeException("cannot find a standard parent form for gmaps4jsf component");
        }

                return parent;
        }

--------------------------
I think the error is 
    ......
    (!(parent instanceof UIForm)))
    ......

because af:form (oracle.adf.view.rich.component.rich.RichForm) extend to 

org.apache.myfaces.trinidad.component.UIXForm (not UIForm)

As i can use gmaps4jsf components with Form ADFaces component (af:Form) ???????

Thanks in advance

Original issue reported on code.google.com by antonios...@gmail.com on 3 Mar 2011 at 8:56

GoogleCodeExporter commented 8 years ago
I bet your problem is solved by now, but I was having the same issue with 3.0.0 
version. 

Now that gmaps4jsf 3.0 dont need Keys, make sure you embed the script within 
the same tag scope. Apparently the parent class was found. (#cannot find a 
standard parent form for gmaps4jsf component)

@Hazem : instructions for embedding gmap is very well documented. We really 
appreciate all the awesome work. Demo examples are awesome. however I assume 
that
for gmap4jsf 3.0 this snippet 
<script 
      type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?sensor=true">
</script> 
...  was embedded in template/layout.xhtml?

I didnt find it in your source, thus it threw me off. But thanks for the demos, 
i comprehend much faster. 

Original comment by avoiding...@gmail.com on 4 Dec 2014 at 10:00