2 Replies Latest reply on Nov 11, 2007 8:24 PM by fabmars

    Same code, different JDK -> Different behaviour!

    demetrio812

      Hi,
      I have a data grid with images, it look like that:


       <h:form>
       <rich:dataGrid id="tabPhotogallery" columns="4" width="100%" columnClasses="thumbnail"
       value="#{articoloHelper.getImmaginiArticolo(idArticolo)}" var="img">
       <a:commandLink style="text-decoration:none;" oncomplete="Richfaces.showModalPanel('mpAnteprima')">
       <f:setPropertyActionListener value="#{img}" target="#{articoloHelper.immagineSelezionata}" />
       <s:graphicImage border="0" value="#{articoloHelper.getImmagineDocumento(img.id, img.tipologiaDocumento.estensione, false)}" />
       </a:commandLink>
       <br/>
       <h:outputText style="font-weight: bold;" value="#{img.nome}" ></h:outputText>
       </rich:dataGrid>
       </h:form>
      


      When the user clicks on one image it update the articoloHelper.immagineSelezionata value with the selected image and show the follow modalPanel:

       <rich:modalPanel id="mpAnteprima" resizeable="false" shadowOpacity="true" shadowDepth="true"
       autosized="true" zindex="2000">
       <f:facet name="header">
       <h:outputText value="#{articoloHelper.immagineSelezionata.nome}" />
       </f:facet>
       <f:facet name="controls">
       <h:form>
       <h:outputLink value="javascript:Richfaces.hideModalPanel('mpAnteprima')">
       <h:graphicImage style="vertical-align: middle" url="/layout/immagini/pulsanti/close.png" border="0" />
       </h:outputLink>
       </h:form>
       </f:facet>
       <a:outputPanel ajaxRendered="true">
       <s:graphicImage rendered="#{articoloHelper.immagineSelezionata!=null}" value="#{articoloHelper.getImmagineDocumento(articoloHelper.immagineSelezionata.id, articoloHelper.immagineSelezionata.tipologiaDocumento.estensione, true)}" />
       <br/><br/><h:outputText value="#{articoloHelper.immagineSelezionata.descrizione}"></h:outputText>
       </a:outputPanel>
       <p align="center">
       <h:outputLink value="javascript:Richfaces.hideModalPanel('mpAnteprima')">
       Chiudi
       </h:outputLink>
       </p>
       </rich:modalPanel>
      


      I had to put an outputPanel with reRendered set to true because putting reRender="mpAnteprima" in the commandLink doesn't the oncomplete javascript open the pane (I think it's a timing issue, because if I put an alert before the showPanel it works, but of course it shows the alert).

      Btw this code works (the panel is in the center of the screen) if I use JDK 1.5 but when I use the jdk 1.6 it is not centered and that is because it first open the panel centering the little panel without image, then it loads the image and autosize without moving the top and left position so it is not centered.

      How can I fix this?

      Thanks

      Demetrio Filocamo

        • 1. Re: Same code, different JDK -> Different behaviour!
          demetrio812

          Anyone?
          I tried ALL combinations! I also tried with a content servlet to do not use the s:graphicImage but the results is the same...

          at the end the only (very bad) workaround I found is to use the setTimeout to call the shoModalPanel function:

          <h:form>
           <rich:dataGrid id="tabPhotogallery" columns="4" width="100%" columnClasses="thumbnail"
           value="#{articoloHelper.getImmaginiArticolo(idArticolo)}" var="img">
           <a:commandLink style="text-decoration:none;" oncomplete="setTimeout('updateMP()', 500);">
           <f:setPropertyActionListener value="#{img}" target="#{articoloHelper.immagineSelezionata}" />
           <s:graphicImage border="0" value="#{articoloHelper.getImmagineDocumento(img.id, img.tipologiaDocumento.estensione, false)}" />
           </a:commandLink>
           <br/>
           <h:outputText style="font-weight: bold;" value="#{img.nome}" ></h:outputText>
           </rich:dataGrid>
           </h:form>
           <script type="text/javascript">
           function updateMP()
           {
           Richfaces.showModalPanel('mpAnteprima');
           }
           </script>
          


          Someone can tell me what am I making wrong? I just want to open a dynamic ajax rendered autosized (so I don't know the final dimension before loading because they depend on the dimension of the image to be shown) modal panel centered in the middle of the screen...

          Thanks...

          Demetrio Filocamo

          • 2. Re: Same code, different JDK -> Different behaviour!
            fabmars

            Beware if your pages contain some Tomahawk code. Tomahawk is screwed on 1.6