2 Replies Latest reply on Oct 19, 2010 4:52 AM by daynol

    mediaOutput and swf

    daynol

      I was trying with this, but cannot watch that swf in the jsp, any idea plz? :S

       

       

      TestJSFBean

      private byte[] mediaData;

       

          public TestJSFBean() {
              try {
                  mediaData = archivoEnBytes("c:\\tempo.swf");
              } catch (FileNotFoundException ex) {
                  Logger.getLogger(TestJSFBean.class.getName()).log(Level.SEVERE, null, ex);
              } catch (IOException ex) {
                  Logger.getLogger(TestJSFBean.class.getName()).log(Level.SEVERE, null, ex);
              }
          }

       

          public byte[] getMediaData() {
              return mediaData;
          }

       

          public void setMediaData(byte[] mediaData) {
              this.mediaData = mediaData;
          }

       

          public byte[] archivoEnBytes(String nombreFichero) throws FileNotFoundException, IOException
        {
              File archivo = new File(nombreFichero);
              byte[] archivoArray = new byte[(int)archivo.length()];
              FileInputStream fIS = new FileInputStream(archivo);
              fIS.read(archivoArray);
              return archivoArray;
        }

       

      public void paintFlash(OutputStream stream, Object data) throws IOException {
              stream.write(mediaData);
              stream.flush();
              stream.close();
          }

       

      test.jspx

      <ui:composition template="./../templates/main.jspx">
              <ui:define name="content">
      <a4j:loadScript src="resource:///org/richfaces/renderkit/html/js/swfobject.js" />
                  <a4j:form id="form1">
                      <h:inputText value="#{TestBean.cadTest}" />
                      <a4j:outputPanel id="flashPanelDynamic">

       

              <a4j:mediaOutput element="object" id="swfLink" style="display: none;" cacheable="false" session="true"
                               createContent="#{TestBean.paintFlash}"  />

       

              <a4j:outputPanel layout="block" id="myFlashContent" style="width: 200px; height: 200px">
                  <a href="http://www.adobe.com/go/getflashplayer">
                      <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
                  </a>
              </a4j:outputPanel>

       

              <script type="text/javascript">
              var flashvars = {};
              var params = {};
              var attributes = {};
              swfobject.embedSWF(#{rich:element('swfLink')}.href, "#{rich:clientId('myFlashContent')}", "200", "200", "9.0.0", false, flashvars, params, attributes);
              </script>

       

          </a4j:outputPanel>
                  </a4j:form>
               </ui:define>
          </ui:composition>