2 Replies Latest reply on Nov 22, 2012 8:31 AM by NRage2

    How to tell when data has reached the client.

    NRage2
      Build JDEVADF_11.1.2.3.0_GENERIC_120914.0223.6276.1

      I'm having some trouble timing activities between the server and a client in my ADF application. The problem begins with the need to use an embedded Silverlight application within my ADF client to edit a specialized document. This part is working well. The problem arises with the timing of data to be sent to the client and the displaying of the Silverlight component.

      I've placed the Silverlight component in an iframe, which I make visible when needed and hiden when not. I send the document down to the client via a hidden bound InputText field, which is then read and passed to Silverlight.

      Now here's the real problem:

      If I update the hidden InputText like this:

      ...
      PushDoc2Client(doc); // updates bound InputText "rdoc"
      RunAtClient("ShowSilverlight();"); // javascript to show iframe
      ...


      public void PushDoc2Client(Long docid)
      {
      DCIteratorBinding dc = (DCIteratorBinding)evaluateEL("#{bindings.DocsView1Iterator}");
      ViewObject vo = dc.getViewObject();
      vo.applyViewCriteria(vo.getViewCriteriaManager().getViewCriteria("GetDoc"));
      vo.ensureVariableManager().setVariableValue("docid", docid);
      vo.executeQuery();
      }

      protected void RunAtClient(String script)
      {
      FacesContext fctx = FacesContext.getCurrentInstance();
      ExtendedRenderKitService erks = null;
      erks =org.apache.myfaces.trinidad.util.Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
      erks.addScript(fctx, script);
      }

      I then create a race condition. Since RenderKitService.addScript sends to the client immediately and is not queued behind the binding update, the iframe/Silverlight component is shown before it has the new document data at the client. Because of this the application cannot present the correct document.

      The question: Is there a way to identify when the data bound UI object has actually received its data? This way I can show the document ONLY after the client has been updated? (serialize the process)

      If anyone can help out or has a better approach, the help would be greatly appreciated.

      Thanks,

      NRage

      Edited by: NRage2 on Nov 21, 2012 11:18 PM
        • 1. Re: How to tell when data has reached the client.
          Frank Nimphius-Oracle
          Hi,

          note that this code
          public void PushDoc2Client(Long docid)
          {
              DCIteratorBinding dc = (DCIteratorBinding)evaluateEL("#{bindings.DocsView1Iterator}");
             ViewObject vo = dc.getViewObject();
             vo.applyViewCriteria(vo.getViewCriteriaManager().getViewCriteria("GetDoc"));
              vo.ensureVariableManager().setVariableValue("docid", docid);
              vo.executeQuery();
          }
          does not update the ADF binding iterator as it bypasses the ADF binding layer. So unless you manually query the data, chances are your input text field does nit show the updated data. Queries should be executed through the iterator binding to ensure the iterator is refreshed

          See this document: http://www.oracle.com/technetwork/developer-tools/adf/learnmore/27-long-running-queries-169166.pdf here on the client side, JS is used to tell when an application no longer is in a busy state, which means control is passed back to the client. You can try and tweak this code and use it when the data is retieved (assuming the data load is initiated by a user action)

          Frank
          • 2. Re: How to tell when data has reached the client.
            NRage2
            Thanks for the help Frank.

            Unfortunately and unless I'm reading the example incorrectly, I can't use the method the link suggests as I'm not initiating from the client. The file viewer loading is driven from a backing bean and looping through a number of documents.

            Ideally, I was hoping there was a way to identify when the client side component (my text field) received its data. Then It could trigger the document viewer to load the data. If this isn't possible, is there a better way to serialize the server->client->server communication such that I can control the flow and timing of the interaction?

            Managing the timing/serialization of client and server interactions seem to be the one weakness I've found in my short time working with ADF. Perhaps more time will help me see things differently as I really like the majority of the architecture.


            I'm not sure what I'm missing with the query execution, perhaps I didn't provide enough information.
            The PushDoc2Client(Long docid) seems to be working well. I haven't had any issues with the data showing up in the text field.

            I've bound it like this:
            In the pagedef.xml file:
            
             <attributeValues IterBinding="DocsView1Iterator" id="FullDoc">
                  <AttrNames>
                    <Item Value="FullDoc"/>
                  </AttrNames>
             </attributeValues>
            
            in my JSF page:
            
             <af:inputText value="#{bindings.FullDoc.inputValue}" id="rdoc"
                  binding="#{backingBeanScope.backing_main1.rdoc}" clientComponent="true" visible="true"
                   label="Label 2"/>
            Thanks again for any further help/direction offered as I've been struggling with this issue for the past several days.

            NRage