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

    a4j:keepAlive and a4j:mediaOutput questions...

    todd Brown Newbie

      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