1 2 Previous Next 17 Replies Latest reply on Oct 9, 2009 2:43 AM by strannik

    a4j:jsFunction and var in datatable

      When using jsFunction inside a datatable(inside a rich:column),

      <r:dataTable var="v" value="#{myBean.list}" ...
      

      and that jsFunction has some method like:

      <a:jsFunction eventsQueue="red"
      name="js_AddAction" action="#{myBean.process(v)}" />
      


      If some element calls that jsFunction on his event,
      <t:inputText value="#{v.property}" onkeypress="js_AddAction();"/>
      
      


      value of the var inside the jsFunction action attribute
      is always the last value of the var in the datatable,not the current value
      of that var.

      I think that this should be possible...





        • 1. Re: a4j:jsFunction and var in datatable

          Can someone tell is this a bug?

          • 2. Re: a4j:jsFunction and var in datatable

            Please,
            help would be very appreciated!

            • 3. Re: a4j:jsFunction and var in datatable

              Please,
              help would be very appreciated!

              • 4. Re: a4j:jsFunction and var in datatable
                ilya_shaikovsky

                provide full page code instead of jsut pieces.. Are your jsFunction defined inside the table?

                • 5. Re: a4j:jsFunction and var in datatable

                   

                  "ilya_shaikovsky" wrote:
                  provide full page code instead of jsut pieces.. Are your jsFunction defined inside the table?

                  Page has a lot of code...But here is the most important fragments of datatable and some logic inside a column.

                  But yes,jsFunction is defined inside a datatable(inside a rich column),
                  and let say that method which calls that jsFunction accepts as an attribute
                  a current var in that datatable...a problem is that var isn't a current..it's last,even the row key var has a 'last' value.


                  <r:dataTable id="tablicaStavkeZarada" width="100%"
                   onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                   onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                   cellpadding="0" cellspacing="0" var="v" rowKeyVar="rb"
                   value="#{stavkaZaposlenik.stavkeZarada}"
                   rendered="#{stavkaZaposlenik.id != 0}">
                  ...
                  

                  <r:column styleClass="kolonaCentriranoGore">
                   <t:panelGrid columns="1" cellpadding="0" cellspacing="0">
                   <t:panelGrid columns="3" cellpadding="0" cellspacing="0">
                   <t:inputText tabindex="#{fokus.tabIndexDatatable()}"
                   id="uvjetVrstaPrimanja" value="#{traziVrstaPrimanja.uvjet}"
                   size="1"
                   onkeypress="return callJsFunctionIfEnterIsPressed(event,'js_vrstaPrimanja');" />
                  
                   <a:jsFunction eventsQueue="red" name="js_vrstaPrimanja"
                   focus="forma:tablicaStavkeZarada:#{rb}:uvjetVrstaPrimanja"
                   action="#{obradaStavkaZarade.dodajVrstaPrimanja(v,traziVrstaPrimanja,0)}"
                   reRender="tablicaStavkeZarada">
                   </a:jsFunction>
                  
                   <t:commandButton image="/slike/ikone/otvoriSifarnik.png"
                   title="#{messages['traziVrstaPrimanja']}" tabindex="-1"
                   style="cursor:pointer"
                   action="#{teleport.inConversationWithTransition(v,'traziVrstaPrimanja')}" />
                   </t:panelGrid>
                   </t:panelGrid>
                  </r:column>
                  


                  • 6. Re: a4j:jsFunction and var in datatable

                    and we are using richfaces 3.1.4.GA

                    • 7. Re: a4j:jsFunction and var in datatable
                      • 8. Re: a4j:jsFunction and var in datatable
                        ilya_shaikovsky

                        in future add the bugs only to RF jira.

                        • 9. Re: a4j:jsFunction and var in datatable
                          ilya_shaikovsky

                          also please check under 3.1.5 release please. (new url - http://jira.jboss.org/jira/browse/RF-3282 )

                          • 10. Re: a4j:jsFunction and var in datatable

                             

                            "ilya_shaikovsky" wrote:
                            in future add the bugs only to RF jira.


                            O.K., in the future, it will be like that.


                            also please check under 3.1.5 release please


                            Tried to run the example with richfaces 3.1.5 GA, but the problem still exists...




                            • 11. Re: a4j:jsFunction and var in datatable
                              strannik

                              Was it fixed in 3.2.1?

                              I've read RF-3282 and Alexander Smirnov note

                              Yes, of course - this code generated a lot of JavaScript functions with same name. Last of them will overwrite all other.
                              For a right functionality, attribute "name" should be unique for an all rows.


                              But it doesn't make sense to use different names for the function. Because we want that our JS function catches up all calls for the function with specific name.

                              • 12. Re: a4j:jsFunction and var in datatable
                                nbelaevski

                                 

                                "Strannik" wrote:
                                Was it fixed in 3.2.1?

                                I've read RF-3282 and Alexander Smirnov note

                                Yes, of course - this code generated a lot of JavaScript functions with same name. Last of them will overwrite all other.
                                For a right functionality, attribute "name" should be unique for an all rows.


                                But it doesn't make sense to use different names for the function. Because we want that our JS function catches up all calls for the function with specific name.

                                That's not a bug really; either put functions to array or declare a single one and move it outside the table.

                                • 13. Re: a4j:jsFunction and var in datatable
                                  strannik

                                  I would love to ... but have no clue how to do that. My code

                                  <rich:dataTable value="#{types}" id="types"
                                   var="type" >
                                   <rich:column sortBy="#{type.name}">
                                   <f:facet name="header">
                                   <h:outputText value="#{msg['type.name']}" />
                                   </f:facet>
                                   <h:outputText value="#{type.name}" />
                                   </rich:column>
                                   <rich:column>
                                   <a4j:commandLink
                                   oncomplete="Richfaces.showModalPanel('confirmation');"
                                   reRender="confirmation">
                                   <a4j:actionparam name="action" value="#{msg['action.delete']}"
                                   assignTo="#{confirmationBean.action}" />
                                   <a4j:actionparam name="subject" value="#{type.name}"
                                   assignTo="#{confirmationBean.subject}" />
                                   <h:graphicImage url="/resources/images/delete.jpg"
                                   alt="#{msg['buttons.delete']}" />
                                   </a4j:commandLink>
                                   <a4j:jsFunction name="processAction" reRender="types"
                                   action="#{adminController.deleteType(type)}" />
                                   </rich:column>
                                   <f:facet name="footer">
                                   <rich:datascroller></rich:datascroller>
                                   </f:facet>
                                   </rich:dataTable>
                                  


                                  So my jsFunction makes a call to controller and needs type parameter (current row variable). If I move jsFunction outside of the datatable type will not be initialized.

                                  • 14. Re: a4j:jsFunction and var in datatable
                                    ilya_shaikovsky

                                    but you could pass the parameter from actual call using f:param.

                                    1 2 Previous Next