1 Reply Latest reply on Apr 1, 2008 7:03 AM by Ilya Shaikovsky

    a4j:mediaoutput NOT WORKING

    Frans Stofberg Newbie

      Guys, I have a problem that I have no idea why its hapening...
      I have a tree where I process the selection of the item (in the applications cace is a reference to an image attatchment Object)
      Now when the processSelection is done and the panel with the image is rerendered the mediaoutput does not call the createContent method if the value attribute is correct, but if the value attribute is null then the createContent method is called (but this is useless as the image data (value) shoud not be null)

      Does this make sence...?

      here is the code

      thanks in advance

      <rich:tree switchType="client" value="#{myWorkListDTO.currentApplication.attatchmentsTree}" var="item"
       ajaxSubmitSelection="true"
       nodeSelectListener="#{myWorkListDTO.currentApplication.processSelection}"
       reRender="imagePanel"
       oncomplete="javascript:Richfaces.showModalPanel('imageModal')">
       </rich:tree>
      
       <rich:modalPanel id="imageModal" zindex="2000" autosized="true">
       <f:facet name="header">
       <h:outputText value="Image" />
       </f:facet>
       <f:facet name="controls">
       <span style="cursor:pointer" onclick="javascript:Richfaces.hideModalPanel('imageModal')">X</span>
       </f:facet>
      
       <rich:panel id="imagePanel" style="width:600px;">
       <rich:messages showDetail="true" showSummary="false" styleClass="error"/>
       <a4j:mediaOutput id="imageMedia" element="img" cacheable="false"
       value="#{myWorkListDTO.currentApplication.selectedAttatchment}"
       createContent="#{myWorkListDTO.currentApplication.paintImage}"
       />
       </rich:panel>
       </rich:modalPanel>


      public void processSelection(NodeSelectedEvent event) {
       UITree tree = (UITree) event.getComponent();
       if (tree.getRowData() instanceof Attatchment) {
       selectedAttatchment = (Attatchment) tree.getRowData();
       }
       else {
       selectedAttatchment = null;
       }
       }


      public void paintImage(OutputStream os, Object data) {
       if (data != null) {
       if (data instanceof ApplicationDTO) {
       Attatchment paintData = (Attatchment) data;
       try {
       os.write(paintData.getAttachmentBytes());
       } catch (IOException e) {
       e.printStackTrace();
       }
       }
       }
       }