1 2 Previous Next 27 Replies Latest reply: Jan 21, 2013 12:01 PM by Roberto Cordoba Go to original post RSS
  • 15. Re: Richfaces 4 datatable rowclick is not hitting the listener method
    Shameer Kunjumohamed Newbie

    Hi Ilya,

     

    I tried your work around, to use the jsFunction for passing the event to the server, with an action(first I tried with actionListener).

     

    It complains method not found(javax.el.MethodNotFoundException).

    What is the expected method signarure ?

    I tried both options(one with an arg, AjaxBehaviorEvent and the other one without any args).

     

    Here is my jsFunction

    jsFunction
    <a4j:jsFunction name="callTestMethod" action="#{myBean.testMethod}"

                   render="elem1, elem2">

            </a4j:jsFunction>

     

    Listener methods
    public void testMethod(AjaxBehaviorEvent event) {

            log.warn(">>>>> Test method[with AjaxBehaviorEvent] ... <<<<");

        }

     

     

        public void testMethod() {

            log.warn(">>>> Test method ... <<<<<");

        }

     

     

    What could be the problem ?

  • 16. Re: Richfaces 4 datatable rowclick is not hitting the listener method
    Ilya Shaikovsky Master

    It should be defined as for any Action component (e.g. commandLink):

        public void listener(AjaxBehaviorEvent event){

            System.out.println("UserBean.UserBean()");

        }

       

        public void actionListener(ActionEvent event){

            System.out.println(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("currentRow"));

            System.out.println("UserBean.actionListener()");

        }

    and

    <a4j:jsFunction name="selectRow" actionListener="#{userBean.actionListener}" render="out" action="#{userBean.action}">

                                  <a4j:param name="currentRow" assignTo="#{userBean.name}"/>

    </a4j:jsFunction>

     

    both called in my case and output proper params.

  • 17. Richfaces 4 datatable rowclick is not hitting the listener method
    Shameer Kunjumohamed Newbie

    It works now, after changing the method signature to ActionEvent, but getting a JS error after the first click. Then stops working.

     

    Message: Invalid argument.

    Line: 1416

    Char: 17

    Code: 0

    URI: http://192.168.0.27:8080/<myApp>/javax.faces.resource/jsf.js.jsf?ln=javax.faces&stage=Development

     

    This is how I call the jsFunction from inside the data-table..

    ==============================

    <a4j:ajax event="rowclick"

                            render="elem1"

                            limitRender="true" onbeforesubmit="callTestMethod()">

    </a4j:ajax>

    ===============================

    In the above example, I tried to fire the event from onbegin as well, same effect.

     

    My listener method is this now

    ===================================

    public void testMethod(ActionEvent event) {

            log.warn(">>>> Test method ... <<<<<");

        }

    ===================================

     

     

    The jsFunction is...

    =====================================

    <a4j:jsFunction name="callTestMethod" action="#{myBean.testMethod}"

                   render="elem1, elem2">

    </a4j:jsFunction>

    =====================================

     

    It works without any errors if I call it on onrowclick of the data-table, but fails when I call from the a4j:ajax.

    Calling from onrowclick of the data-table will not be sufficient for me, as I need to apply limitRender on the rowClick, which is not possible in this option, for that I need a4j:ajax.

     

    The only difference I could observe from your jsFunction is, mine doesn't have a param.

     

    Can you show me the code that invokes the jsFunction ? I want to see both cases, with and without a a param.

    Is it possible to pass the reference of a complex object(such as #{userBean}) as an argument to this jsFunction ?

  • 18. Richfaces 4 datatable rowclick is not hitting the listener method
    Shameer Kunjumohamed Newbie

    This JS error is only in IE. I use IE version 8. It works in Mozilla.

  • 19. Richfaces 4 datatable rowclick is not hitting the listener method
    Shameer Kunjumohamed Newbie

    Ilya,

     

    Can you tell me how do I call this JS method from inside a datatable ? I want to pass the reference of the currentRow.

  • 20. Re: Richfaces 4 datatable rowclick is not hitting the listener method
    Ilya Shaikovsky Master

    I can't check error it right now (will ping other guys to help because I have no Win environment now)..

     

    But wondering why you using such chain? rowclick - ajax - jsFunction... For me it has no sence. jsFunction allows to define all the same properties ioncluding limitRender. In general all the RF components which sends ajax requests has standartized attributes applied. So you have no need to mix them.

     

    As Jay written

    Ilya just updated the jira with a code sample- RF-10824

    and there is the code including calling the JS function and passing parameters

  • 21. Re: Richfaces 4 datatable rowclick is not hitting the listener method
    Shameer Kunjumohamed Newbie

    I am sorry, I didnt see the work around description properly..

     

    Now I can pass params to the server. But still I do not see a way to pass an object reference to server. I want to pass the currentRow to the listener method (Not the key or a string).

     

    Earlier with RF3, I was able to pass pass the currentRow as an attribute of a4j:support element, which is not possible with the a4j:ajax now. I can set attributes to only a component, as per JSF 2. How can I pass it using this JS work around ?

     

    With the rowclick - ajax - jsFunction chain, I was trying to pass/set the object reference to server while(before) invoking the jsFunction. It didnt work though.

  • 22. Re: Richfaces 4 datatable rowclick is not hitting the listener method
    Ilya Shaikovsky Master

    it was possible with setPropertyActionListener in context of the row when support was UIComponent and not a behavior and was able to process action listeners. But now you're out of row context with that workaround. So have to use a4j:param which is works passing params to client and sending back rather than just processing at server side as f: tag does. So have two ways to try:

    1) still pass just #{car} to jsFunction and perform assign to the object of the corresponding type. But as a4j:param sending params to client on rendering and passing back on submit -  you will need converter for that object.

    2) more easy from my point of view. passing the object property by which you could identify the object(#{car.id}). And perform lookup at server side.

  • 23. Richfaces 4 datatable rowclick is not hitting the listener method
    Shameer Kunjumohamed Newbie

    Even this JS work around has an issue, the parameter that I set to a bean property is actually set after the listener method is executed. So what happens is, I get the property value at server after one more row-click. The result is - I am always getting the row-key of the previous click inside the listener method. Is there a way to get this set before the method invocation ?

     

    Right now, I am patching this by adding one more work around(over the original work around). I am calling an intermediate jsFunction(with a blank listener method) that sets the param first and then call the actual listener method onbegin of the first jsFunction, which is really dirty. It looks as given below.

     

            <a4j:jsFunction name="beforeRowClickListener" actionListener="#{myBean.beforeRowClicked}" render=""

            limitRender="true" onbegin="rowClickListener()">

                 <a4j:param name="rowKey" assignTo="#{myBean.currentRowKey}"/> 

             </a4j:jsFunction>

     

            <a4j:jsFunction name="rowClickListener" actionListener="#{myBean.rowClicked}" render="elem1, elem2,.."

            limitRender="true">

             </a4j:jsFunction>

     

    I don't know if it happens to me only, because of a missing tag attribute, please correct me with the right usage.

  • 24. Richfaces 4 datatable rowclick is not hitting the listener method
    Ilya Shaikovsky Master
    • a4j:param works as actionListener under the hood.
      • listeners in JSF 2 has next order of execution - 1) listeners added using nested tags(e.g. f:actionListener, a4j:actionListener) 2) listeners defined at the component itself (attribute of the ui command)
      • So that's why you getting such result. And that's just as it should works according to JSF spec.

    Two options of solution there:

    • if want to leave your listener defined with attribute - get the parameter from request map instead of relying on assignTo.
    • remove actionListener attribute from jsFunction and instead add a4j:actionLisnter tag nested to jsFunction after the parameter and use listener attribute which should point to the same beforeRowClicked method.
  • 25. Richfaces 4 datatable rowclick is not hitting the listener method
    Shameer Kunjumohamed Newbie

    I tried the second option, and it worked.

     

    Thanks Ilya.

  • 26. Re: Richfaces 4 datatable rowclick is not hitting the listener method
    ashutosh deora Newbie

    I am facing the problem of single click action fire throughout my project

    We are doing migration from RF 3 to RF 4 .

    it now seems to be a very trobled water for us .

    Please can @Ilya help .

    We are on deadline for delivering but this is not hapeneing .

    Please help .

  • 27. Re: Richfaces 4 datatable rowclick is not hitting the listener method
    Roberto Cordoba Newbie

    Hi Jay, Ilya,

     

       I have same problem as Paul. Is it already fixed?

     

    I´m sorry guys, I´m completely sure you work as beasts, but I totally agree with Paul. I had my application almost finished in Richfaces 3.3, but I decided to migrate to RF4, to be on the track. My experience is the migration is being really painful. I´m really unhappy with my decision.

     

    For me, it is not about if there is a workaround for the issue but the issue is quite common functionality. To be able to pick up with an ajax request the data in a row. Come on guys. All applications have this.

     

    Sorry for being so hard this time. I know you are really helpful for a lot of people and really appreciate your work.

     

    Regards,

    Roberto.

1 2 Previous Next