1 Reply Latest reply on Aug 11, 2009 4:57 AM by Ilya Shaikovsky

    rich:columns, rich:column visible attribute : show/hide colu

    ARUN PRAKASH GANESAN Newbie

      I have searched through google for more elaborate way of using this particular attribute to show/hide columns in a dynamic manner

      Richfaces 3.3.2
      Jboss 4.3 EAP
      Linux/Windows/Solaris
      Myfaces 1.2.5


      Here is my code

      <rich:scrollableDataTable
      frozenColCount="# {itemController.grid.frozenColCount}"
      height="500px"
      width="1200px"
      id="grid"
      rows="40"
      value="#{itemController.grid.rows}" var="row"
      rowKeyVar="rowKey"
      hideWhenScrolling="true"
      rowClasses="row1,row2"
      >
      <rich:columns value="#{itemController.grid.columns}"
      var="column"
      index="ind" id="dynaColumn"
      sortable="false"
      visible="#{column.visible}"
      >

      <f:facet name="header" >
      <h:outputText value="#{column.name}"
      styleClass="richDataTableHeaderFont"/>
      </f:facet>

      <a4j:commandLink id="expandCollapse" value="#{row.cells[ind].ref.expandable ? !row.cells[ind].ref.expanded?'[ + ]':' [ - ]': ''}" rendered="#{ind==0}" onclick="expandCollapseColumn(#{rowKey},#{ind})"/>

      </rich:columns>
      </rich:scrollableDataTable>

      Here is my demo class structure

      public class Grid {

      public class Column {
      private String name;
      private String value;
      private boolean visible;

      //getter setters for all the variables

      }

      }

      When i add the visible attribute i get this exception. I can't seem to find out what is wrong. I can use the "rendered " attribute to show/hide columns but more appropriate would be the visible attribute.

      org.apache.jasper.JasperException: /datatable.jsp(69,3) Unable to find setter method for attribute: visible
      org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
      org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
      org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
      org.apache.jasper.compiler.Generator$GenerateVisitor.evaluateAttribute(Generator.java:2736)
      org.apache.jasper.compiler.Generator$GenerateVisitor.generateSetters(Generator.java:2965)
      org.apache.jasper.compiler.Generator$GenerateVisitor.generateCustomStart(Generator.java:2169)
      org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1689)
      org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)
      org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
      org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
      org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1705)
      org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)
      org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2336)
      org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2386)
      org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1705)
      org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1507)

        • 1. Re: rich:columns, rich:column visible attribute : show/hide
          Ilya Shaikovsky Master

           

          <ui:composition xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:a4j="http://richfaces.org/a4j"
           xmlns:rich="http://richfaces.org/rich">
           <h:form>
           <rich:scrollableDataTable value="#{dataTableScrollerBean.model}" var="model" width="800px" id="table">
          
           <f:facet name="header">
           <h:outputText value="Cars Available"></h:outputText>
           </f:facet>
          
           <rich:columns value="#{dataTableScrollerBean.columns}" var="columns" visible="#{columns.visible}"
           index="ind" id="column#{ind}" sortBy="#{model[ind].price}" sortOrder="#{columns.sortOrder}">
          
           <f:facet name="header">
           <h:outputText value="#{columns.header}" />
           </f:facet>
          
           <h:outputText value="#{model[ind].model} " />
           <h:outputText value="#{model[ind].mileage} miles " />
           <h:outputText value="#{model[ind].price}$"
           style="font-style:italic;" />
          
           </rich:columns>
          
           </rich:scrollableDataTable>
           <a4j:commandButton action="#{dataTableScrollerBean.showAllColumns}" value="show all columns" reRender="table"/>
           </h:form>
          </ui:composition>
          

          and
           public void showAllColumns() {
           for (Facet column : columns) {
           column.setVisible(true);
           }
           }
          


          this slightly changed code from RF demo (columns sample, dataTAble changed to scrollable and action to show added). works fine for me.