8 Replies Latest reply on Jul 9, 2009 8:57 AM by nbelaevski

    a4j:mediaOutput

    iimirela

      Hello,

      I'm having problems with the media output. I tried the exmple from the live demo page, but it does not work for me.

      In my xhtml, I have

      <a4j:outputPanel id="flashPanelDynamic">
      
       <a4j:mediaOutput element="a" id="swfLink" style="display: none;" cacheable="false" session="true"
       createContent="#{Bean.paintFlash}" value="#{mediaData}" />
      
       <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>
      



      In my bean I have the paintFlash and copy methods, and I added the MediaData bean.

      Ok, I must mention that the swf is in another war (I'm trying to integrate 2 projects), but this is not the problem. I've put a breakpoint inside the paintFlash method, but the method is not called.

      Plus how can I send flashvars?

      Thank you,
      Ioana.


        • 1. Re: a4j:mediaOutput
          iimirela

          I fixed the problem partially. I was a matter of

          <context-param>
           <param-name>org.richfaces.LoadScriptStrategy</param-name>
           <param-value>ALL</param-value>
          </context-param>
          

          in the web.xml file.

          Now.. the fact that the swf is in another war is a problem :)
          How can I call it? And pass flashvars?

          Thanks,
          Ioana.

          • 2. Re: a4j:mediaOutput
            nbelaevski

            Hi Ioana,

            Why not use SWF file directly? E.g.

            swfobject.embedSWF("/anothercontext/flash/my.swf", ...)
            without a4j:mediaOutput?

            • 3. Re: a4j:mediaOutput
              iimirela

              Because it's a dynamic thing, and I need to specify in java what to show, so a4j:mediaoutput is very confy. In the paintFlash method is there a way to get the swf in another context?

              Thanks,
              Ioana.

              • 4. Re: a4j:mediaOutput
                nbelaevski

                I'm not sure what dynamical do you mean, so how about this:

                swfobject.embedSWF("#{bean.movieUrl}", ...)
                ?
                If this doesn't work for you, then you can try forwarding request to SWF resource; however this solution will work better with custom-coded Servlet and without a4j:mediaOutput, because I do not see a good place to include forwarding in its code.

                • 5. Re: a4j:mediaOutput
                  iimirela

                  I meant dynamic in the sense that not always I have to show a swf.

                  I have a tree menu, and in base of the selected leaf, I show a swf, or an image, or smth else.

                  Thanks.
                  Ioana.

                  • 6. Re: a4j:mediaOutput
                    nbelaevski

                    Ioana,

                    Then you can hide/show a4j:outputPanel holding SWF. E.g. using "rendered".

                    • 7. Re: a4j:mediaOutput
                      iimirela

                      Hi,

                      Yes, I'll render/rerender :) but I have to dynamically decide the content of the outputpanel. Maybe you'll disagree, but I did smth like this int the paintFlash method:

                      javax.faces.context.ExternalContext ext = FacesContext.getCurrentInstance().getExternalContext();
                      HttpServletRequest request = (HttpServletRequest)ext.getRequest();
                      
                      ServletContext context = request.getSession(). getServletContext).getContext("/otherContext");
                      
                      InputStream stream = context.getResourceAsStream("/myflex.swf");
                      


                      And it works for me.

                      Ioana.



                      • 8. Re: a4j:mediaOutput
                        nbelaevski

                        Hi Ioana,

                        Nice to hear it's working.