RichFaces 4 DataTable rich:column styling issue

252 Views Asked by At

I am migrating a jboss seam, richfaces 3.x and jsf 1.x application to jboss seam 2.3 and richfaces 4 and jsf 2.x. I have a rich:dataTable which displays some data, the styling of the column is evaluated using value expression which in the first load works. My requirement is whenever i click on a row there is a call to the backing bean method which sets the clicked row object as selected and at the complete of the ajax i render the table again, but the classes are not applied to the selected row or which was clicked. I have the classes defined in a css file included in tags.

  My view Code goes here: 

  <rich:dataTable id="table" value="#{backingBean.getRows()}" var ="top" onrowClick="#{rich:element('rowClickButton')}.click();">
    <rich:column styleClass="#{top.selected ? 'selected':'unselected'>
      <a4j:commandButton id="rowClickButton" style="display:none" render="#{top.selected ? 'table':null} action ="#{bean.setRowclicked(top)}"/>
      <h:outputText value="First Column"/>
   </rich:column>
   <rich:column styleClass="#{top.selected ? 'selected' : 'unselected'>
      <h:outputText value="Second Column"/>
   </rich:column>

 My Backing Bean goes here

 public class BackingBean(){ 

     public List<Rows> getRows(){
       List<Rows> rows = new ArrayList<Rows>();
       rows.add(row1);
       rows.add(row2);
      return rows ;
   }   
 public void setRowClicked(top){
   top.selected(true);
 } 

}

PS : i am taking the approach of creating a button and hiding it inside the column because the rowClick on a4j:ajax didnt work and i need the object 'top' to be passed to the backing bean, any optimisation or a better approach to this also is very much appreciated and welcomed.

0

There are 0 best solutions below