Hi,

We've got some code that worked with Tomahawk 1.1.1, but doesn't work with Tomahawk 1.1.3.

A managed bean has a binding to a commandButton component that is in a table.

The tomahawk datatable's rowOnClick functionality is used to output javascript for each row that clicks a button embedded in the row. In order to do this, we use binding to make the button component accessable to the managed bean that generates the javascript, so it has access to the button's client id.

  <t:dataTable id="loss-event-search-results"
        rendered="#{!pageBean.noRecords}"
        var="row"
        binding="#{pageBean.table}"
        value="#{pageBean.sortedRows}"
        rowIndexVar="rowIndex"
        rowOnClick="#{pageBean.rowOnClickScript}">
...
   <t:column>
    ...
      <%-- Hidden button that handles row selection --%>
      <t:commandButton binding="#{pageBean.editCommand}" id="edit" ...>
<t:updateActionListener property="#{pageBean.selectedRowIndex}" value="#{rowIndex}" /> </t:commandButton> </t:column>

  private UIComponent editCommand;
  // getter and setter for editCommand omitted..

   public String getRowOnClickScript() {
       String editCommandId = editCommand.getClientId(context);
       return "document.getElementById('" + editCommandId + "').click()";
   }

Unfortunately when the page is rendered, the editCommand member of the backing bean is set but it points to a UICommand instance that is *different* from the one actually being rendered. Because of this, editCommand.getClientId is returning an id that does not have a rowIndex value embedded (because the ancestor UIData component has not had its setRowIndex method called), and our javascript is therefore wrong.

BTW, pageBean is an alias for the actual bean name.

Does anyone have any idea how a binding can somehow become "detached" like this? The managed bean is session-scope, but as I understand things when the view is rendered the binding expression is read, and if an object is returned then it is reused, and if not then a new object is created and the setter is called to assign the binding. We appear to only have
the setter called once.


Thanks,

Simon

Reply via email to