7 Replies Latest reply on Sep 24, 2007 10:41 AM by nayanj

    how to force ajax region refresh

    nayanj


      I have some code for which reRender does not refresh the ajax region. I will like to force refresh for the component. How can I do it? right now, I am invoking a javascript using the oncomplete attribute to reload the entire page but that has some undesirable effects.

        • 1. Re: how to force ajax region refresh
          damianharvey

          Show your code.

          Ensure that you aren't trying to reRender a region that has a "rendered" attribute. Eg:
          This won't reRender:

          <s:div id="renderId" rendered="#{myBean.render"}>...</s:div>

          But this will:
          <s:div id="renderId">
           <s:div rendered="#{myBean.render}">...</s:div>
          </s:div>


          Cheers,

          Damian.


          • 2. Re: how to force ajax region refresh
            nayanj

            Here you go:

            <h:form>
            <a:region id="treeRegion">
            <rich:tree id="tree" switchType="ajax" style="width:300px" value="#{library.data}"
             var="item" nodeFace="#{item.type}" showConnectingLines="false"
             binding="#{dataSourceTree}" componentState="#{library.treeState}">
             <rich:treeNode id="leafNode" type="leaf" iconLeaf="img/blank.gif" nodeClass="checkbox">
             <h:selectBooleanCheckbox id="serviceCheckbox" value="#{item.selected}" styleClass="checkbox">
             <a:support event="onclick" actionListener="#{item.setSelected}" RequestDelay="3" reRender="treeRegion" immediate="true"/>
             </h:selectBooleanCheckbox>
             <h:outputText id="leafText" value="#{item.name}" />
             </rich:treeNode>
            
             <rich:treeNode id="categoryNode" type="leafCategory" icon="img/blank.gif" nodeClass="checkbox">
             <h:selectBooleanCheckbox id="categoryCheckbox" value="#{item.selected}" styleClass="checkbox">
             <a:support event="onclick" actionListener="#{item.setSelected}" RequestDelay="3" reRender="treeRegion" immediate="true"/>
             </h:selectBooleanCheckbox>
             <h:outputText id="categoryText" value="#{item.name}" />
             </rich:treeNode>
            
             </rich:tree>
            </a:region>
            </h:form>
            


            tried lot of things.. reRender just don't seem to work in this case..

            • 3. Re: how to force ajax region refresh
              damianharvey

              Is your action getting hit when you tick the checkbox? Try putting an <a4j:log/> on your page and then viewing the log using the default CRTL-SHIFT-L.

              Also, try enclosing the a4j:region in an s:div and reRendering that instead.

              Cheers,

              Damian.

              • 4. Re: how to force ajax region refresh
                wise_guybg

                I agree with Damian that the problem might come from trying to reRender the region.

                BTW I don't know why people on this forum don't like a4j:outputPanel and use all kinds of seam tags (s:div, s:decorate). Anyways, not important...

                • 5. Re: how to force ajax region refresh
                  damianharvey

                  I normally use s:div as that is how I lay out my markup.

                  • 6. Re: how to force ajax region refresh
                    alanlynott

                    We've experienced lots of problems with rerendering a4j:outputpanels and have switched to s:div to resovle the problems.

                    The problem appears to be with RichFaces so I'm hoping the future release that incorporates ajax4jsf removes these problems.

                    But for now switch to s:div.

                    • 7. Re: how to force ajax region refresh
                      nayanj

                       

                      Is your action getting hit when you tick the checkbox?


                      Yes. The action gets hit and updates the "selected" property of "item" in the entire subtree.
                      I have tried s:div and a:outputPanel, the output does not change. Only way I have been able
                      to update the subtree is doing a page refresh (which also confirms action was hit).

                      Try putting an <a4j:log/> on your page and then viewing the log using the default
                      CRTL-SHIFT-L.

                      Following is the log. There seems to be an error which makes no sense to me.

                      debug[9:12:20,803]: Have Event [object Object] with properties: target:
                       [object HTMLInputElement], srcElement: undefined, type: click
                      debug[9:12:20,803]: NEW AJAX REQUEST !!! with form :treeForm
                      debug[9:12:20,803]: parameter treeForm:tree:2:_id8 with value treeForm:tree:2:_id8
                      debug[9:12:20,803]: Start XmlHttpRequest
                      debug[9:12:20,803]: Reqest state : 1
                      debug[9:12:20,818]: QueryString: AJAXREQUEST=treeForm ... truncated(too long)
                      debug[9:12:20,818]: Reqest state : 1
                      debug[9:12:23,397]: Reqest state : 2
                      debug[9:12:23,397]: Reqest state : 3
                      debug[9:12:23,397]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 3
                      debug[9:12:23,412]: Reqest state : 4
                      debug[9:12:23,412]: Reqest end with state 4
                      debug[9:12:23,412]: Response with content-type: text/xml;charset=UTF-8
                      debug[9:12:23,412]: Full response content: truncated (too long)
                      debug[9:12:23,428]: Update page by list of rendered areas from response treeForm:treeDiv
                      debug[9:12:23,428]: search for elements by name 'script' in element #document
                      debug[9:12:23,428]: getElementsByTagName found 20
                      debug[9:12:23,428]: <script> in response with src=/myproj/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.seam
                      debug[9:12:23,428]: Such element exist in document
                      debug[9:12:23,428]: <script> in response with src=/myproj/a4j.res/prototype.js.seam
                      debug[9:12:23,428]: Such element exist in document
                      debug[9:12:23,428]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/json/json.js.seam
                      debug[9:12:23,428]: Such element exist in document
                      debug[9:12:23,428]: <script> in response with src=/myproj/a4j.res/dnd.js.seam
                      debug[9:12:23,428]: Such element exist in document
                      debug[9:12:23,428]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/dnd/dnd-common.js.seam
                      debug[9:12:23,428]: Such element exist in document
                      debug[9:12:23,428]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/dnd/dnd-draggable.js.seam
                      debug[9:12:23,428]: Such element exist in document
                      debug[9:12:23,428]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/dnd/dnd-dropzone.js.seam
                      debug[9:12:23,428]: Such element exist in document
                      debug[9:12:23,428]: <script> in response with src=/myproj/a4j.res/org/ajax4jsf/framework/ajax/scripts/AJAX.js.seam
                      debug[9:12:23,443]: Such element exist in document
                      debug[9:12:23,443]: <script> in response with src=/myproj/a4j.res/org/ajax4jsf/renderkit/html/scripts/form.js.seam
                      debug[9:12:23,443]: Such element exist in document
                      debug[9:12:23,443]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/events.js.seam
                      debug[9:12:23,443]: Such element exist in document
                      debug[9:12:23,443]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/tree.js.seam
                      debug[9:12:23,443]: Such element exist in document
                      debug[9:12:23,443]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/tree-selection.js.seam
                      debug[9:12:23,443]: Such element exist in document
                      debug[9:12:23,443]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/tree-item.js.seam
                      debug[9:12:23,443]: Such element exist in document
                      debug[9:12:23,443]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/tree-item-dnd.js.seam
                      debug[9:12:23,443]: Such element exist in document
                      debug[9:12:23,443]: <script> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/scripts/drag-indicator.js.seam
                      debug[9:12:23,443]: Such element exist in document
                      debug[9:12:23,443]: search for elements by name 'link' in element #document
                      debug[9:12:23,443]: getElementsByTagName found 2
                      debug[9:12:23,443]: <link> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/css/dragIndicator.xcss/DATA/eAGz-yBjAQAEPAGD.seam
                      debug[9:12:23,459]: Such element exist in document
                      debug[9:12:23,459]: <link> in response with src=/myproj/a4j.res/org/richfaces/renderkit/html/css/tree.xcss/DATA/eAGz-yBjAQAEPAGD.seam
                      debug[9:12:23,459]: Such element exist in document
                      debug[9:12:23,459]: Attempt to update part of page for Id: treeForm:treeDiv
                      debug[9:12:23,459]: call getElementById for id= treeForm:treeDiv
                      debug[9:12:23,490]: Replace content of node by replaceChild()
                      debug[9:12:23,506]: search for elements by name 'script' in element div
                      debug[9:12:23,506]: getElementsByTagName found 5
                      debug[9:12:23,506]: Scripts in updated part count : 5
                      debug[9:12:23,506]: Update part of page for Id: treeForm:treeDiv successful
                      debug[9:12:23,522]: call getElementById for id= ajax-update-ids
                      debug[9:12:23,522]: Hidden JSF state fields: [object HTMLSpanElement]
                      debug[9:12:23,522]: search for elements by name 'input' in element span
                      debug[9:12:23,522]: getElementsByTagName found 3
                      debug[9:12:23,522]: Replace value for inputs: 32 by new values: 3
                      debug[9:12:23,522]: Input in response: jsf_tree_64
                      debug[9:12:23,522]: Found same input on page with type: hidden
                      debug[9:12:23,522]: Found same input on page with type: hidden
                      debug[9:12:23,522]: Found same input on page with type: hidden
                      debug[9:12:23,522]: Input in response: jsf_state_64
                      debug[9:12:23,522]: Found same input on page with type: hidden
                      debug[9:12:23,522]: Found same input on page with type: hidden
                      debug[9:12:23,522]: Found same input on page with type: hidden
                      debug[9:12:23,522]: Input in response: jsf_viewid
                      debug[9:12:23,537]: Found same input on page with type: hidden
                      debug[9:12:23,537]: Found same input on page with type: hidden
                      debug[9:12:23,537]: Found same input on page with type: hidden
                      debug[9:12:23,537]: search for elements by name 'INPUT' in element span
                      debug[9:12:23,537]: getElementsByTagName found 0
                      debug[9:12:23,537]: Replace value for inputs: 32 by new values: 0
                      debug[9:12:23,584]: Evaluate script replaced area in document: // LOG.registerPopup('L','LogWindow',800,600,LOG.ALL); // //
                      debug[9:12:23,584]: Evaluate script replaced area in document: // LOG.registerPopup('L','LogWindow',800,600,LOG.ALL); // //
                      debug[9:12:23,584]: Evaluate script replaced area in document: // var Richfaces_Tree_treeForm_tree = new Tree("treeForm:tree",
                       "treeForm:tree:input", "ajax", { onselect: "", onexpand: "", oncollapse: "" },
                       function(event) { A4J.AJAX.Submit('treeForm:treeRegion','treeForm',event,
                       {'parameters':{'treeForm:tree:selectedNode':event.selectedNode},
                       'actionUrl':'/myproj/main.seam'}); return false; }, "" );
                       Richfaces_Tree_treeForm_tree.drop = function(event,drag){var options =
                       {'parameters':{'treeForm:tree':'treeForm:tree'},'actionUrl':'/myproj/main.seam'};
                       options.parameters['dropTargetId'] = 'treeForm:tree';
                       Object.extend(options.parameters,drag.getParameters());
                       if (this.options.ondrop) { if (!this.options.ondrop.call(this, event)) return; };
                       A4J.AJAX.Submit('treeForm:treeRegion','treeForm',event,options);}; // //
                      error[9:12:23,584]: . Error message: this.elements.contentTd has no properties
                      debug[9:12:23,584]: Evaluate script replaced area in document: // // //
                      debug[9:12:23,600]: Evaluate script replaced area in document:
                       // LOG.registerPopup('L','LogWindow',800,600,LOG.ALL); // //