6 Replies Latest reply on Feb 16, 2012 2:00 AM by joesepp1974

    RF 4.2 a4j:mediaOutput

    joesepp1974 Newbie

      Hi!

       

      I have a question about a4j:mediaOuput:

       

      I am creating an image content with JFreeChart and showing it with a4j:mediaOuput. This works very fine, but when I want to update the chart with a a4j:commandButton and render of the a4j:mediaOutput, I can not see the new chart.

      I checked to documentation about examples and attributes, but did not find a solution.

       

      Here is my code:

      <a4j:mediaOutput id="img" element="img" cacheable="false" createContent="#{mbj3.readChartData}" value="WochenChart" mimeType="image/png" title="WochenChart"/>

       

      I have seen that there is another attribute called "expires". But which value should I give to it, that there is no caching and the chart is rerendered on every button-click?

       

      Thanks in advance!

        • 1. Re: RF 4.2 a4j:mediaOutput
          iabughosh Master

          hello joesepp,

          i think your value attribute must be something like this :

          value="{mbj3.WochenChar}" not value="WochenChart"

           

          and try also adding session="true" attribute to your a4j:mediaOutput.

           

          regards.

          • 2. Re: RF 4.2 a4j:mediaOutput
            joesepp1974 Newbie

            Hi Ibrahim!

             

            The "value" attribute is not the problem. this attribute takes an object, so my string with the name of the chart to create is working fine.

             

            I tried the "session" attribute, but "session" is not definded in the component´s interface and it did not work.

             

            The chart is shown correct loading the page for the first time, but when I want to reload the chart with ajax, the a4j:mediaOutput is not calling the "createContent" method in my bean, and it still shows the old chart.

            When I make a complete page refresh without ajax, the updated chart is shown correct. So it is only the question how I can force the a4j:mediaOuput to call the "createContent" method and show the actualized chart.

             

            greetings

            • 3. Re: RF 4.2 a4j:mediaOutput
              iabughosh Master

              could you post more code of your .xhtml page?.

              • 4. Re: RF 4.2 a4j:mediaOutput
                joesepp1974 Newbie

                here is the complete page code:

                 

                <?xml version="1.0" encoding="windows-1252"?>
                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

                <html xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:a4j="http://richfaces.org/a4j"
                      xmlns:rich="http://richfaces.org/rich"
                      >

                  <h:head>
                  <meta http-equiv="X-UA-Compatible" content="IE=9"/>
                    <title>
                      Test
                    </title>
                  </h:head>
                  <h:body>
                    <h:form id="masterForm">
                      baseValueForChart: <h:outputText id="baseValueForChart" value="#{testBean.zahl}"/>
                      <br/>
                      <a4j:mediaOutput id="chart" element="img" cacheable="false" createContent="#{mbj3.readChartData}" value="WochenChart" mimeType="image/png" title="WochenChart" />
                      <br/>
                      <a4j:commandButton value="update" render="chart,baseValueForChart" actionListener="#{testBean.test2()}"/>
                    </h:form>
                  </h:body>
                </html>

                when i click the button, the actionListener creates a new chart and renders the baseValueForChart with the new value, but the a4j:mediaOutput don´t calls the "createContent".

                 

                • 5. Re: RF 4.2 a4j:mediaOutput
                  iabughosh Master

                  i think your problem is in render attribute:

                  <a4j:commandButton value="update" render="chart,baseValueForChart" actionListener="#{testBean.test2()}"/>

                   

                  you can separate by two elements using space , try render="chart baseValueForChart" or render="@form"

                   

                  regards.

                  • 6. Re: RF 4.2 a4j:mediaOutput
                    joesepp1974 Newbie

                    ich tried both proposals, but the result is the same.