0 Replies Latest reply on Jul 29, 2008 5:06 AM by Maxime Frachon

    rich:tree and a4j:poll value method always call

    Maxime Frachon Newbie

      Hello everyone,

      I’ve got a problem with rich:tree and a4j:poll.


      Code:

      Tree File

      <a4j:form style="display: inline;" id="arbre_form">
       <ratp:block styleClass="treeContainer">
       <h:panelGroup>
       <rich:tree
       rendered="true"
       ajaxSingle="true"
       switchType="ajax"
       value="#{Arbre.modelTree}"
       var="item"
       nodeFace="#{item.type}"
       id="arbre_materiel"
       binding="#{Arbre.tree}"
       iconCollapsed="${basePath}/styles/images/icones/collapsed.gif"
       iconExpanded="${basePath}/styles/images/icones/expanded.gif"
       reRender="arbre_form">
       <rich:treeNode
       type="SCG"
       rendered="true">
       <f:facet name="icon">
       <h:graphicImage
       title="#{ArbreMessages['arbre.mcca']}"
       url="#{item.openPicturePath}" />
       </f:facet>
       <f:facet name="iconLeaf">
       <h:graphicImage
       alt="inactif"
       url="#{item.closedPicturePath}" />
       </f:facet>
       <rich:dropDownMenu
       event="oncontextmenu"
       verticalOffset="-1000"
       value="#{item.libelle}">
       <rich:menuItem>
       </rich:menuItem>
       </rich:dropDownMenu>
       </rich:treeNode>
       <rich:treeNode
       type="STANDARD_TREE_TYPE"
       rendered="true">
       <f:facet name="icon">
       <h:graphicImage
       title="#{item.titlePicture}"
       alt="#{item.titlePicture}"
       url="#{item.openPicturePath}" />
       </f:facet>
       <f:facet name="iconLeaf">
       <h:graphicImage
       title="#{item.titlePicture}"
       alt="#{item.titlePicture}"
       url="#{item.closedPicturePath}" />
       </f:facet>
       <a4j:htmlCommandLink
       id="cmdContextMenu"
       value="#{item.libelle} (#{item.nbChilds})"
       action="#{item.doActionOnClick}"
       styleClass="#{item.outputTextStyleClass}"
       onmouseover="javascript:updateFilter('#{item.filtre}', '#{item.uid}');">
       <f:param
       name="id"
       value="#{item.id}" />
       <f:param
       name="param1"
       value="#{item.param1}" />
       <rich:componentControl event="oncontextmenu" attachTo="cmdContextMenu" for="arbreContextMenu" operation="show">
       </rich:componentControl>
       </a4j:htmlCommandLink>
       </rich:treeNode>
       <rich:treeNode
       type="AUTORISATION_TREE_TYPE"
       rendered="true">
       <f:facet name="icon">
       <h:graphicImage
       title="#{item.titlePicture}"
       alt="#{item.titlePicture}"
       url="#{item.openPicturePath}" />
       </f:facet>
       <f:facet name="iconLeaf">
       <h:graphicImage
       title="#{item.titlePicture}"
       alt="#{item.titlePicture}"
       url="#{item.closedPicturePath}" />
       </f:facet>
       <a4j:htmlCommandLink
       value="#{item.libelle}"
       action="#{item.doActionOnClick}">
       <f:param
       name="id"
       value="#{item.id}" />
       <f:param
       name="param1"
       value="#{item.param1}" />
      
       </a4j:htmlCommandLink>
       </rich:treeNode>
       <rich:treeNode
       type="BASE_TREE_TYPE"
       rendered="true">
       <f:facet name="icon">
       <h:graphicImage
       title="#{item.titlePicture}"
       alt="#{item.titlePicture}"
       url="#{item.openPicturePath}" />
       </f:facet>
       <f:facet name="iconLeaf">
       <h:graphicImage
       title="#{item.titlePicture}"
       alt="#{item.titlePicture}"
       url="#{item.closedPicturePath}" />
       </f:facet>
       <h:outputText value="#{item.libelle}" />
       </rich:treeNode>
       </rich:tree>
       </h:panelGroup>
       </ratp:block>
      
       <rich:contextMenu id="arbreContextMenu"
       onexpand="javascript:document.getElementById('html:body:arbre_form:valueToFiltreArbre').value=document.getElementById('hiddenFilter').value;
       document.getElementById('html:body:arbre_form:idTreeArbre').value=document.getElementById('hiddenIdTree').value;"
       oncollapse="javascript:contextMenuOpened = false;"
       submitMode="none"
       rendered="true"
       attached="false">
       <rich:menuItem id="arbreRichMenuItem">
       <h:panelGrid columns="3" id="arbrePanelridMenuItem">
       <h:outputText value="#{ArbreMessages['arbre.filtre']}: "/>
       <h:panelGroup>
       <h:inputText id="valueToFiltreArbre" size="6" value="#{Arbre.filtre}" />
       </h:panelGroup>
       <a4j:commandLink
       action="#{Arbre.filtre}"
       reRender="arbre_materiel">
       <h:graphicImage
       value="/styles/images/icones/valid.gif"
       style="cursor:pointer" />
       </a4j:commandLink>
       <h:inputHidden id="idTreeArbre" value="#{Arbre.idTree}" />
       </h:panelGrid>
       </rich:menuItem>
       </rich:contextMenu>
      
      
       <script>
      
      
      
       function updateFilter(newValue, idTreeValue){
       document.getElementById('hiddenFilter').value = newValue;
       document.getElementById('hiddenIdTree').value = idTreeValue;
       }
      
      
       </script>
       <input type="hidden" id="hiddenFilter" value=""/>
       <input type="hidden" id="hiddenIdTree" value=""/>
       </a4j:form>


      Poll file:

      <a4j:form>
      <a4j:poll
       interval="1000"
       action="#{InformationBean.updateAction}"
       />
      </a4j:form>


      When the a4j:poll is called, the linked method to the value of the tree (#{Arbre.modelTree}) is called (the tree is not rerender).

      In fact on each ajax request, this method is called whereas I don't rerender the tree.

      Is there any problem in my code?