0

I have simple primefaces remoteCommand in composite component that won't trigger method in back bean.

<h:form id="frm1" prependId="false">
         <p:remoteCommand name="rc1" 
            actionListener="#{Bean1.preloadMenu()}" 
            process="@this"
            onstart="alert('xxx')"
            autoRun="true"
         />
         ...

RemoteCommand works, it runs onstart client-side script but it doesn't trigger method in bean (never steps into method, as if it doesn't exist). I get no error on client or server side.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Zivko
  • 367
  • 5
  • 16
  • possible duplicate of [commandLink/commandButton/ajax backing bean action/listener method not invoked](http://stackoverflow.com/questions/2118656/commandlink-commandbutton-ajax-backing-bean-action-listener-method-not-invoked) – Kukeltje Mar 05 '15 at 08:57
  • I can only relate to item 8 – Zivko Mar 05 '15 at 09:52
  • If a parent of the with the UICommand button is been rendered/updated by an ajax request beforehand, then the first action will always fail. The second and subsequent actions will work. This is caused by a bug in view state handling which is reported as JSF spec issue 790 and currently scheduled to be fixed in JSF 2.3. For older JSF versions, you need to explicitly specify the ID of the in the render of the , or to use the script in this answer. – Zivko Mar 05 '15 at 09:52
  • But I had similar situation before with composit compoent inside dialog wich is render after some action on page and evrything works fine inside component and dialog (all buttons fired corrctly, not sure did I have remote one) – Zivko Mar 05 '15 at 09:54
  • Omnifaces has a fix for this to for current releases of jsf – Kukeltje Mar 05 '15 at 10:57

1 Answers1

1

I'll close this topic. I resolved this issue by putting code in initialize (@PostConstruct) methode. Didn't want to do it like that but this dialog isn't used too often and bean is associated just with this component so it shouldn't do much damage.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Zivko
  • 367
  • 5
  • 16