1 Reply Latest reply on Aug 21, 2015 6:39 AM by Sathish Kumar

    a4j:jsfunction vs calling method directly from javascript

    S Reddy Newbie

      I'm new to RichFaces. I have a requirement to call backingbean method from javascript. I used a4j:jsfuction to do so but I was adviced not to use this component for performance and call backing bean method directly within javascript like below

      within javascript:


      within xhtml:

         function somemethod(value){



      Can you please let me know which approach is better and why?


      Thanks in advance.

        • 1. Re: a4j:jsfunction vs calling method directly from javascript
          Sathish Kumar Newbie

          Hi Reddy,


          a4j:jsFunction has it's own specific functionalities. If you want to just a backing bean method to be called you can call like what you have posted. But if you want to display the updated content after the backing bean method is called, it is better to use the rich faces tag a4:jsFunction, because it has the function like render, onbegin, oncomplete,onbeforedomupdate.


          Just For example (Not efficient logical vice)

          public class userBean


              private String userName;

              public String getUserName()


                    return this.userName;


              public void setUserName(String userName)


                    this.userName = userName;




          public class ActionController(){

              public string updateUserName(HttpRequest request)


                    String tempUserName = "NewUserName";


                    return page;





          Assume that you want to update the password and want to display the updated password. Then you have to call the jsFunction

          <a4j:jsFunction name="updateUserName" action="#{actionController.updateUserName}" render="passPopupPanel" limitRender="true" execute="@this" 

          oncomplete="#{rich:component('passPopupPanel').show()}"/>  (tag according to richfaces 4)


          passPopupPanel is rich:popupPanel which shows the updated password

          This is the use of the a4j:jsFunction