Topic
7 replies Latest Post - ‏2012-07-30T22:32:07Z by SystemAdmin
SystemAdmin
SystemAdmin
6420 Posts
ACCEPTED ANSWER

Pinned topic Ajax Refresh Request

‏2012-07-27T03:06:44Z |
Hi Guys - I have been breaking my head on this issue, appreciate if someone can provide any help on this.

<h:panelGroup styleClass="panelGroup" id="claimsSummaryGroup">
<h:outputText styleClass="outputText" id="claimNumber"
value="#{pc_JSFProjectView.claimNumberInt}"></h:outputText>
</h:panelGroup>
<hx:ajaxRefreshRequest target="claimsSummaryGroup"
id="ajaxRefreshRequest1">
</hx:ajaxRefreshRequest>

Basically I need to keep on refreshing the claimsSummaryGroup until one of the flag is set to true.

I have tried the following scenarios: -
1. I added the hx:bheaviour tag onload of this panel group, but it just fires only the first time. I tried to place inside this panel group, but it does not work.
2. I have added a output link and a behavior tag onclick of it and tried to fire the onclick using the javascript, it does not work. It works only when I click it using the mouse.

Is there any way I can keep on refreshing the panel group? Any suggestions are welcome.
Updated on 2012-07-30T22:32:07Z at 2012-07-30T22:32:07Z by SystemAdmin
  • yurykats
    yurykats
    2186 Posts
    ACCEPTED ANSWER

    Re: Ajax Refresh Request

    ‏2012-07-27T13:47:58Z  in response to SystemAdmin
    This should give you an idea: http://www.ibm.com/developerworks/rational/library/07/0626_kats/index.html#ajax
    • SystemAdmin
      SystemAdmin
      6420 Posts
      ACCEPTED ANSWER

      Re: Ajax Refresh Request

      ‏2012-07-27T16:51:02Z  in response to yurykats
      Thanks for the response. I think I was not clear on what I was trying to achieve. Basically I have a long datatable, for which I need to asynchronously fetch the rows, initially there will be 10 rows when the page renders and this recursive ajax request will keep on appending adding another 10 set of records to the datatable until we are done with all the rows.

      Couple of strategies I was thinking about: -
      1. Have a hx:behavior tag for a onclick on a button which is hidden which in turns calls a ajax request tag, I tried to fire a event on the button through javascript but the behavior tag does not get fired. But when I click the button then behavior tag works. Is there any way I can this working?
      2. Also tried some research on the hx client library, but not making good progress because of lack of documentation.
      3. Tried some other approaches but not successful.

      Thanks,
      • SystemAdmin
        SystemAdmin
        6420 Posts
        ACCEPTED ANSWER

        Re: Ajax Refresh Request

        ‏2012-07-30T17:46:15Z  in response to SystemAdmin
        Guys - Anyone have any ideas, please help. Thanks.
        • SystemAdmin
          SystemAdmin
          6420 Posts
          ACCEPTED ANSWER

          Re: Ajax Refresh Request

          ‏2012-07-30T21:46:03Z  in response to SystemAdmin
          Based on yurykats comments, I followed the article more closely. I created a simple example , seems like there is bug in the IBM JSF extension tag unless if someone points anything wrong in my code. Here is my code: -

          <f:view>
          <hx:scriptCollector id="scriptCollector1">
          <portlet:defineObjects />
          <script type="text/javascript">
          function func_3(thisObj, thisEvent) {
          alert("onActionFunction is called");
          return true;
          }
          dojo.addOnLoad(function(){
          alert("Add On Load function");
          var linkObj = dojo.byId("view<portlet:namespace/>:form1:button11");
          linkObj.click();
          });
          </script>
          <h:form styleClass="form" id="form1">
          <h:panelGroup styleClass="panelGroup" id="claimsSummaryGroup">
          <h:outputText styleClass="outputText" id="claimNumber"
          value="#{pc_JSFProjectView.claimNumberInt}"></h:outputText>
          </h:panelGroup>
          <hx:ajaxRefreshRequest target="claimsSummaryGroup"
          id="ajaxRefreshRequest1">
          </hx:ajaxRefreshRequest>

          <h:commandButton type="button" id="button11" value="Button">
          <hx:behavior event="onclick" id="behavior11" behaviorAction="get"
          targetAction="claimsSummaryGroup"
          onActionFunction="return func_3(this, event);">
          <hx:behavior event="onActionFunction" id="behavior11212"></hx:behavior>
          </hx:behavior>
          </h:commandButton>
          </h:form>
          </hx:scriptCollector>
          </f:view>

          The dojo addonload function triggers a click on the button, but the hx:behavior tag does not notice it. It only notices when I manually click the button. Anything I am missing? Any suggestions? Here are the versions that I am using (I made sure I checked for updates and my RAD is updated): -

          jsf-ibm.jar
          Manifest-Version: 1.0
          Ant-Version: Apache Ant 1.8.2
          Created-By: IBM Corporation
          Specification-Title: Java Server Faces
          Implementation-Title: JSF Widget Library (JWL) - Base
          Implementation-Version: JWL v3_1_12
          Implementation-Vendor: IBM
          Build-Version: 20111011.1036
          Build-Date: October 11 2011
          Copyright-Info: Copyright (c) 2003,2008, International Business Machin
          es Corporation. All Rights Reserved.

          WebSphere Portal 6.1
          RAD 7.5.5

          Thanks again.
          • SystemAdmin
            SystemAdmin
            6420 Posts
            ACCEPTED ANSWER

            Re: Ajax Refresh Request

            ‏2012-07-30T22:18:49Z  in response to SystemAdmin
            Hello, instead of using the dojo library to make a click just use:

            function submitFunc(){
            document.getElementById('form1:button11').click();
            }
            window.onload = submitFunc();

            But this will loop, just add some condition to stop the clicking.
            • SystemAdmin
              SystemAdmin
              6420 Posts
              ACCEPTED ANSWER

              Re: Ajax Refresh Request

              ‏2012-07-30T22:32:06Z  in response to SystemAdmin
              I tried your variant also, but I still dont see the hx:behavior notices this.

              Thanks.
            • SystemAdmin
              SystemAdmin
              6420 Posts
              ACCEPTED ANSWER

              Re: Ajax Refresh Request

              ‏2012-07-30T22:32:07Z  in response to SystemAdmin
              I tried your variant also, but I still dont see the hx:behavior notices this.

              Thanks.