7 Replies Latest reply on Apr 30, 2010 8:25 AM by harut

    <a4j:actionparam> question

    roykachouh

      How can I get at the value property of this tag via Javascript.

      I have a table populated with values and when the user clicks on one of the rows, I would like to be able to use javascript to set the value property and then submit the ajax request.

      Here is what I have:

      <a4j:actionparam id="rawMessageID" value="1" assignTo="#{SEND_CLOSE_REQUEST_AJAX.corporateActionID}"/>


      I would like to be able change the "value" property using javascript.

      When I view the generated html source, i see that my param is generated as follows:

      'top10Form:rawMessageID':'1'


      How can I use something in JavaScript, like document.getElementById to get at this?

      Thanks.

      Roy Kachouh

        • 1. Re: <a4j:actionparam> question

          a4j:actionparam has a noEscape attribute. if it is set to true, the value will be evaluated as a javascript code.

          For example,
          ....

          <script>
          ...
           var foo = "bar";
          ...
          </script>
          ...
          ...
          
          <a4j:actionParam noEscape="true" name="param1" value="foo" assignTo="#{bean.prop1}" />
          ...



          it might be any javascript function there. Like:
          <a4j:actionParam noEscape="true" name="param1" value="getMyTableRowIndex()" assignTo="#{bean.prop1}" />
          ...

          if you have this function, the result of it will be taken.

          So, clicking the row, set some javascript var that is referenced by no escaped value like it shown above.

          P.S. NOTE: a4j:param extends f:param, so the "name" attribute is mandatory. Otherwise, the value will be missing due missing the request parameter name for it. The doc (#1) is not pretty much accurate about this issue.

          P.P.S. noEscape has no effect along with non-ajax action component such as h:commandLink. The doc is right there.

          #1 http://labs.jboss.com/file-access/default/members/jbossajax4jsf/freezone/docs/tlddoc/index.html


          • 2. Re: <a4j:actionparam> question
            roykachouh

            Thanks! It worked like a charm.

            • 3. Re: <a4j:actionparam> question
              klonikar

              How can pass value of "var" for the selected row(s) to the backing bean java code?

              • 4. Re: <a4j:actionparam> question
                ilya_shaikovsky

                 

                <rich:column>
                 <a4j:command* ...>
                 <a4j:actionParam name="..." value="#{cap.name}">
                 </a4j:command>
                </rich:column>
                


                there, cap is variable defined in var attribute. or you mean something else?

                • 5. Re: <a4j:actionparam> question
                  klonikar

                  I meant something similar, but wanted to pass the whole "var" object in one shot. Something like passing domain object for the selected row.

                  Currently, the org.richfaces.model.selection.Selection class allows accessing the selected row indices when dealing with ScrollableDataTable. But the row indices in the data list are not the same as displayed when you sort on some columns. Also, the rows indices are relative to one page scrolled in a page scroller.

                  Instead of row indices, it would be better to access the domain object ("var") associated with the selected row.

                  • 6. Re: <a4j:actionparam> question

                    We use a datatable like the below and need to send the entire 'var' attribute to the beacking bean thru actionparam..

                     

                     

                    <h:dataTable id="dtResults" value="#{SearchBean.lstSrchResults}"
                         var="result" columnClasses="col15,col85">
                         <h:column>
                         ....
                         ....
                            <a4j:support event="onclick"  ajaxSingle="true" immediate="true"
                                requestDelay="1"  disableDefault="true">
                                <a4j:actionparam  name="checkedFile" value="#{result}"
                                 assignTo="#{SearchBean.selFile}"
                                 actionListener="#{SearchBean.addToCart}" />
                             </a4j:support>
                        ....
                        </h:column>
                    </h:dataTable>
                    

                     

                    By doing so, we encounter a 'javax.el.ELException' on the actionListener and a null pointer in the bean, where the 'assignTo' attribute is accessed.

                     

                    Pls clarifiy whether is this the right way to acheive this.

                     

                     

                    Thanks,

                    Ram

                    • 7. Re: <a4j:actionparam> question
                      harut

                      It is imosspible to send your bean object by a4j:actionparam... it is request parameter so it can be any String but not a bean object...