javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1258

jsf standard component 'dataTable' uses inconsistent column classes

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Incomplete
    • Affects Version/s: current
    • Fix Version/s: 2.0.0-b18
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,258

      Description

      There is a inconsistent behaviour of the 'h:dataTable' component with respect to
      CSS style classes:

      The inconsistency show up, if the table is used in an ajaxified context and one
      its 'h:column' subcomponents has a 'rendered' attribute that is bound to a
      modifiable property ('show/hide' this column). If the table is being rerendered,
      the wrong column classes are applied.

      Reason: during 'encode' the 'columnClasses' attribute obviously is used
      independently from the 'rendered' stated of the h:columns subcomponents. Correct
      and consistent behaviour would be to skip those column classes from the
      'columnClasses' list, that are currently not to be rendered.

      A workaround is possible (though a little bit expensive in terms of development
      effort): supply the 'columnClasses' attribute dynamically from a backing bean
      and trigger its regeneration after the column selection (rendered-attribute) has
      been modified.

      My code for this workaround:

      private StringBuffer columnClassesAsStringBuffer = new StringBuffer();

      public final String getColumnClassesAsString() {
      return columnClassesAsStringBuffer.toString();
      }

      // called by some apply-values/value-changed-event on 'column-rendered'
      private void updateColumnClassesString() {
      // produce String for columnClasses:
      columnClassesAsStringBuffer.setLength(0);
      for (TreeTableColumnMetaData col : tableColMetaData)

      { if (col.getHideColumn()) continue; // ,,,FH should be done by JSF dataTable component when h:column's 'rendered' attribute yields false if (columnClassesAsStringBuffer.length() > 0) columnClassesAsStringBuffer.append(","); columnClassesAsStringBuffer.append(col.getCellClass()); }

      }

        Activity

        Hide
        Ryan Lubke added a comment -

        Target for FCS.

        Show
        Ryan Lubke added a comment - Target for FCS.
        Hide
        driscoll added a comment -

        Take ownership.

        Show
        driscoll added a comment - Take ownership.
        Hide
        driscoll added a comment -

        While I agree that the behavior you describe is awkward, it is behaving both
        consistently - it may also be behaving as specified.

        It's consistent, since I don't see a change in behavior between the ajax and
        non-ajax cases.

        If I have three columns, and three column classes (one, two, three), then
        if the first column is rendered=false, the second column will get class one, and
        the third column will get class two, regardless of whether the rendered
        attribute is dyanmic or a constant, and regardless of whether it's an ajax
        request or a full request. You imply in your bug report that that's not what
        you're seeing - if so, let me know.

        I need to check on what the desired behavior is from a spec perspective before
        proceeding on this bug.

        Show
        driscoll added a comment - While I agree that the behavior you describe is awkward, it is behaving both consistently - it may also be behaving as specified. It's consistent, since I don't see a change in behavior between the ajax and non-ajax cases. If I have three columns, and three column classes (one, two, three), then if the first column is rendered=false, the second column will get class one, and the third column will get class two, regardless of whether the rendered attribute is dyanmic or a constant, and regardless of whether it's an ajax request or a full request. You imply in your bug report that that's not what you're seeing - if so, let me know. I need to check on what the desired behavior is from a spec perspective before proceeding on this bug.
        Hide
        driscoll added a comment -

        OK, I've checked with the specification lead, and this is in fact working as
        specified.

        As you surmise, if you're going to be dynamically changing the rendered
        attribute of the different columns, you'll also have to dynamically change the
        columnClasses string value.

        If you think that JSF should have different behavior, then by all means please
        file a specification feature request, under
        http://javaserverfaces-spec-public.dev.java.net/

        Show
        driscoll added a comment - OK, I've checked with the specification lead, and this is in fact working as specified. As you surmise, if you're going to be dynamically changing the rendered attribute of the different columns, you'll also have to dynamically change the columnClasses string value. If you think that JSF should have different behavior, then by all means please file a specification feature request, under http://javaserverfaces-spec-public.dev.java.net/
        Hide
        Manfred Riem added a comment -

        Closing resolved issue out

        Show
        Manfred Riem added a comment - Closing resolved issue out

          People

          • Assignee:
            driscoll
            Reporter:
            frankwhofmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: