0

I'm using p:ajax in a primefaces slider and treenode. whenever I expand the tree, the oncomplete method is always called automatically. Can anyone tell me how to stop this automatic call


<p:tree value="#{Bean.root}" var="node" dynamic="true">
 <p:ajax event="expand"  
  oncomplete="PF('primefacesPersoDialog').initPosition()" /> 
  <p:treeNode> 
   <p:outputPanel rendered="#{something ..}">
    <div style="styling ..">
     <h:outputText style="styling .."
       value="#{node.name }" />
        <p:outputPanel style="styling ..">
         <h:inputHidden id="aaa"
          value="#{node.selection}" />
         <p:slider for="aaa" step="1" maxValue="2"  style="styling .." > 
          <p:ajax event="slideEnd"  
           listener="#{bean.methodOne}" 
           oncomplete="#{bean.methodTwo(node)}" 
           update="@this" process="@this" />
         </p:slider> 
        </p:outputPanel>
       </div>
      </p:outputPanel>
      </p:treeNode>
      </p:tree>
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • So doing a comparable thing in an `f:ajax` in a `h:commandButton` works? – Kukeltje Apr 17 '18 at 09:21
  • even f:ajax didn't work for me – Omar Khbou Apr 17 '18 at 09:27
  • See, it is not PrimeFaces related... Not even ajax (same would happen doing an `onclick` on a commandButton in plain jsf without ajax). So it is not javascript related either... – Kukeltje Apr 17 '18 at 09:29
  • This is the 'better' duplicate btw https://stackoverflow.com/questions/29096643/how-to-invoke-a-managed-bean-action-method-in-on-attribute-of-a-jsf-component and/or https://stackoverflow.com/questions/8705614/how-to-call-jsf-backing-bean-method-only-when-onclick-oncomplete-on-event-occ – Kukeltje Apr 17 '18 at 09:30
  • guys this is not a duplicate, I've already checked all the answers you mentioned and even much more and i did not find any solution – Omar Khbou Apr 17 '18 at 09:33
  • Sorry, you are plain out wrong, 100000%... it IS a duplicate. You **CANNOT** add a EL reference to a Java server side method in the oncomplete.... Just is not how it works.... – Kukeltje Apr 17 '18 at 09:49
  • And the **java** method in `oncomplete="#{bean.methodTwo(node)}"` (javascript has functions) is called when the node is expanded is because you have `dynamic="true"` on the tree. If you remove that, it will be called (multiple times, once for each node) And if you checked all posts and did not notice the oncomplete is wrong that is remarkable. – Kukeltje Apr 17 '18 at 10:24
  • if you have `` Primefaces will call `initPosition()`after every expand of your tree. That's what you wanted. – Holger Apr 17 '18 at 11:00
  • @Holger I'm not talking about that oncomplete, it's the other one (oncomplete="#{bean.methodTwo(node)}" ) that is always automatically called – Omar Khbou Apr 17 '18 at 11:56
  • @Omar But not from oncomplete. Oncomplete is a javascript call. Your `bean.methodTwo(node)` may be called when the slider is rendered, but never ever if oncomplete is activated after the ajax call of the slider. – Holger Apr 17 '18 at 14:12

0 Answers0