2 Replies Latest reply on Dec 11, 2014 9:33 AM by Scott Carpenter Branched from an earlier discussion.

    popupPanel doesn't work properly with autosize and mediaoutput

    Scott Carpenter Newbie

      Thanks. It's more than just the header adding height.

       

      Here's the markup:

       

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:ui="http://java.sun.com/jsf/facelets"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:a="http://richfaces.org/a4j"
                      xmlns:rich="http://richfaces.org/rich">
      
      
      <h:form style="margin: 0;">
          <rich:popupPanel id="imageModalPanel" autosized="true"
                           minWidth="425" minHeight="500"
                           moveable="true" top="50"
                           show="#{instance.getCurrentPhotoId() != 0}"
                           domElementAttachment="parent">
              <f:facet name="header">
                  <h:panelGroup styleClass="widget-details-section-header">
                      <div class="widget-details-section-header-left">
                          <h:outputText value="Photo:  #{instance.name}"/>
                      </div>
                  </h:panelGroup>
              </f:facet>
              <f:facet name="controls">
                  <h:panelGroup>
      
      
                      <a:commandLink execute="@this" id="hideFullPhoto"
                                     actionListener="#{instance.setCurrentPhotoId(0)}"
                                     title="#{messages['close']}" styleClass="close-button-icon"
                                     render="imageModalPanel"/>
      
      
                  </h:panelGroup>
              </f:facet>
              <a:mediaOutput id="fullPhoto" element="img"
                             createContent="#{imageLoader.paintImageFullPhoto}"
                             value="#{instance.currentPhotoId}"
                             styleClass="widget-photo">
                  <a:ajax event="click"
                          listener="#{instance.setCurrentPhotoId(0)}"
                          render="imageModalPanel"/>
              </a:mediaOutput>
          </rich:popupPanel>
      </h:form>
      

       

      (Weird. Could see it in editor but not in my reply. Edited to try XML...)

       

      And paintImageFullPhoto ends up here:

       

      public void paintImage(
          final OutputStream out,
          final Object data,
          int imageWidth
      ) throws IOException {
      
      
          if (null == data || !(data instanceof Long)) {
              return;
          }
      
      
          final Long mediaId = (Long) data;
          String photoPath = getPhotosPath(mediaId, imageWidth);
      
      
          if (StringUtils.isNullOrEmpty(photoPath)) {
              return;
          }
      
      
          byte[] content = null;
      
      
          try {
              content = getFileContents(photoPath);
          } catch (FileNotFoundException e) {
              LOG.error("Couldn't find photo from path: " + photoPath + "; " + e.getMessage());
          } catch (IOException e) {
              LOG.error("Error loading photo data for: " + photoPath + "; " + e.getMessage());
          }
      
      
          if (content != null) {
              out.write(content);
          }
      }
      
      
      
      

       

      And getFileContents is essentially:

       

      String fileUrl = getPhotoServerUrlBackend() + filePath;
      
      
      try {
          URL urlPhotos = new URL(fileUrl);
          content = getUrlContents( urlPhotos );
      } catch (Exception e) {
          LOG.info(
              "Error getting content from url: " + fileUrl + " " + e.getMessage()
          );
      }
      
      
      
      

       

      Not sure if you need more than that, and also note that I'm updating some old RF3.3.3 stuff so maybe I've missed something with those changes.