3 Replies Latest reply on Mar 14, 2011 10:05 AM by shikida

    a4j:keepAlive and a4j:mediaOutput questions...

    tb01923

      frameworks: facelets 1.1.12, rich-faces: 3.1.0

      The intent is to be able to clip the big image witha little on by clicking on the little one. Stored inside my bean is an array which has the metric positions (corresponding to the charts on the screen (in this case two positions)). The chart bean is an inner class, constructed by the getLineChart method, passing in the metric.

      It appears as though the createContent="#{algoMulti.lineChart.render}"
      of the mediaOutput is not being rerendered correctly. Whe I debug the request as it comes through (say using fiddler) it always requests the image in its original state.

      <a4j:keepAlive beanName="algoMulti" ajaxOnly="false"/>
       <a4j:outputPanel id="image0" style="height: 200px; " layout="block">
       <a4j:mediaOutput
       element="img"
       cacheable="false"
       session="false"
       createContent="#{algoMulti.lineChart.render}"
       value=""
       mimeType="image/png" >
       <f:param name="m" value="#{algoMulti.summaryMethod}" />
       <f:param name="p0" value="#{algoMulti.reportHandle}" />
       <f:param name="p1" value="#{algoMulti.startStr}" />
       <f:param name="p2" value="#{algoMulti.endStr}" />
       <f:param name="p3" value="#{algoMulti.chartMetric}" />
       <f:param name="p4" value="#{algoMulti.benchmarkSelection}" />
       <f:param name="p5" value="#{algoMulti.idx}" />
       </a4j:mediaOutput>
       </a4j:outputPanel>
       <a4j:outputPanel style="height: 200px; margin-top: 10px; margin-right: 5px">
       <a4j:commandLink reRender="image0, image1" action="${algoMulti.flipMetric}">
       <a4j:actionparam value="1" assignTo="${algoMulti.metricIdx}"/>
       <a4j:outputPanel id="image1">
       <a4j:mediaOutput
       element="img"
       border="0"
       cacheable="false"
       session="false"
       createContent="#{algoMulti.smallLineChartA.render}"
       value=""
       mimeType="image/png" >
       <f:param name="m" value="#{algoMulti.summaryMethod}" />
       <f:param name="p0" value="#{algoMulti.reportHandle}" />
       <f:param name="p1" value="#{algoMulti.startStr}" />
       <f:param name="p2" value="#{algoMulti.endStr}" />
       <f:param name="p3" value="#{algoMulti.chartMetricA}" />
       <f:param name="p4" value="#{algoMulti.benchmarkSelection}" />
       <f:param name="p5" value="#{algoMulti.idx}" />
       </a4j:mediaOutput>
       </a4j:outputPanel>
       </a4j:commandLink>
       </a4j:outputPanel>


      seen behaviour:

      0) Main page is rendered...

      a) construct MultiAlgo()

      1) Click on image to flip

      RESTORE_VIEW
      b) MultiAlgo(exisiting)->setMetricIdx()
      c) MultiAlgo(exisiting)->flipImage()

      RESTORE_VIEW
      d) construct MultiAlgo()
      e) MultiAlgo(new1)->getSmallLineChartA

      RESTORE_VIEW
      f) construct MultiAlgo()
      g) MultiAlgo(new2)->getLineChart()


      The issue occurs becuase a new instance of the Bean is created before calling getLineChart() reverting the array back to the original position. This is confusing to me for two reasons. 1) a4j:keepAlive should prevent new construction (i thought) and 2) should the getLineChart be called in the ajax request inorder to paint the outputPanels correctly? It is apparently deffering until the get for the image...

      intended bevaiour (in my mind):

      ) Main page is rendered...

      a) construct MultiAlgo()

      1) Click on image to flip

      RESTORE_VIEW
      b) MultiAlgo(exisiting)->setMetricIdx()
      c) MultiAlgo(exisiting)->flipImage()
      d) a4j:outputPanel (image0) is updated with new a4j:mediaOutput referencing the flipped image
      e) a4j:outputPanel (image1) is updated with new a4j:mediaOutput referencing the flipped image

      RESTORE_VIEW
      f) a4j:mediaOutput - calls in new image

      RESTORE_VIEW
      g) a4j:mediaOutput - calls in new image

      Thank you in advance


        • 1. Re: a4j:keepAlive and a4j:mediaOutput questions...
          alexsmirnov

          You have two incorrect actions on the page.
          First, images is rendered in different requests, so keepAlive is not applicable to createContent mathod calls.
          As a Second, "param" components din't applicable to mediaOutput component.
          Right solution :
          1) create "render" method as stateless, thread-safe.
          2) put all rendering parameter into Serialisable bean, and put reference to it in "value" attribute. Value will be serialised into image url. In the request to image, this value will be de-serialised and put as parameter to "render" method.

          • 2. Re: a4j:keepAlive and a4j:mediaOutput questions...
            tb01923

            Thank you for your reply.

            I understand that is the typical usage pattern. But this is inherited code, so I am trying to change as little as possible. SHouldn't the createContent call be renrendered as part of the first ajax request (rendering the correct image tag)? I agree that the image is and should be rendered on subsequent requests... ...but the tag that represents and references the image should be renderedd in the first one.. ..no?

            • 3. Re: a4j:keepAlive and a4j:mediaOutput questions...
              shikida

              it would be great if this information was available in the mediaoutput doc pages

               

               

               

              Leo K.