2 Replies Latest reply on Sep 10, 2013 9:53 AM by user10867691

    af:inlineFrame executes its source attribute three times


      I have inserted an inlineframe in a jsf page fragment.


      Initially, the inline frame is visible=false.


      The page fragment also contains a af:commandButton thatn makes visible=true on the inline frame when it is clicked.


      This is the definition of the inlineframe and the button:


               <af:commandButton text="#{viewcontrollerBundle['ALU.GENERAR_EXTRACTO']}"





                                  disabled="true"  partialTriggers="soc1"/>

               <af:inlineFrame binding="#{backingBeanScope.extractoNotasBB.if1}"



                                shortDesc="Listado pdf" visible="false"  partialTriggers="cb1"



      Well, when the page is initially loaded, the URLIframe methos is executes three time.


      When the button is clicked, method URLIframe_action is correctly executes only once:


          public String URLIframe_action() {


              return null;



      but #{backingBeanScope.extractoNotasBB.URLIframe} is again executed three times.


      The problem is that the url called by #{backingBeanScope.extractoNotasBB.URLIframe} have to be mandatory executed only once when clicking the button (which I think is also the expected behaviour)


      What can I do ?


      Thank you.

        • 1. Re: af:inlineFrame executes its source attribute three times
          Dimitar Dimitrov

          If it is important to perform the URL calculation only once, you can move the calculation to the button's action listener. Then store the calculated URL in a view-scoped variable and make the IFrame's "source" attribute referepoint to this variable instead of to a backing bean method:


          public String URLIframe_action() {
            // Calculate the URL and store it in a view-scoped variable
            String iframeURL = this.getURLFrame();
            AdfFacesContext fctx = AdfFacesContext.getCurrentInstance();
            fctx.getViewScope().put("iframeURL", iframeURL);
            return null;


          <af:inlineFrame binding="#{backingBeanScope.extractoNotasBB.if1}"
                          shortDesc="Listado pdf" visible="false" partialTriggers="cb1"/>





          P.S. It is better to use the "actionListener" attribute of the command button instead of the "action" attribute since you are not going to navigate anywhere. Also it is better to use "rendered" attribute of <af:inlineFrame> instead of "visible", because if you use "visible" the IFrame's rendition is always prepared (even if it is not being displayed), which is unnecessary overhead. The example below has added a "Hide Frame" button and has made everything declaratively:


          <af:commandButton id="cb1" text="Show Frame" partialSubmit="true">
            <af:setPropertyListener from="#{backingBeanScope.extractNotasBB.URLIframe}" to="#{viewScope['iframeURL']}" type="action"/>
          <af:commandButton id="cb2" text="Hide Frame" partialSubmit="true">
            <af:setPropertyListener from="#{null}" to="#{viewScope['iframeURL']}" type="action"/>
          <af:panelGroupLayout partialTriggers="cb1 cb2">
            <af:inlineFrame source="#{viewScope['iframeURL']}" rendered="#{viewScope['iframeURL']!=null}"/>
          • 2. Re: af:inlineFrame executes its source attribute three times

            Thank you Dimitar.


            It has worked ok, but could you please explain me why this method "#{backingBeanScope.extractoNotasBB.URLIframe}" executed three times before ? This means that the source parameter of inlineframe is calculated three times, doesn't it ?