Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4226

TreeColumn not displayed when there is only one "Alignment.MIDDLE" column

    XMLWordPrintableJSON

Details

    Description

      When you create a TreeTable with only one column in the middle (Alignment.MIDDLE), the column is not display in the browser.

      When you look at the HTML code, the width is set to 00%:
      ...
      <div class="a_">
      <span class="b_" style="width:00%">
      <span class="c_">...
      </span>
      </div>
      ...

      The error comes from the MiddleColumnsView class where the number is formatted :

      /**

      • @see org.apache.wicket.MarkupContainer#onRender()
        */
        @Override
        protected void onRender()
        {
        Response response = RequestCycle.get().getResponse();
        double widths[] = computeColumnWidths();

      NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH);
      nf.setMaximumFractionDigits(0);
      nf.setMaximumIntegerDigits(2); // <--------- Should be nf.setMaximumIntegerDigits(3); to handle value > 99

      for (int i = 0; i < columns.size(); ++i)
      {
      Component component = components.get;
      IRenderable renderable = renderables.get;
      IColumn column = columns.get;

      // write the wrapping column markup
      response.write("<span class=\"b_\" style=\"width:" + nf.format(widths[i]) + "%\">");

      To reproduce you can use the TreeTablePage class from wicket example and keep only one "middle" column :
      ...
      IColumn columns[] = new IColumn[]

      { new PropertyTreeColumn<String>(new ColumnLocation(Alignment.MIDDLE, 8, Unit.PROPORTIONAL), "Tree Column (middle)", "userObject.property1"), new PropertyRenderableColumn<String>( new ColumnLocation(Alignment.RIGHT, 8, Unit.EM), "R1", "userObject.property6"), }

      ;
      ...

      Attachments

        1. MiddleColumnsView.patch
          0.4 kB
          Gabriel Landon

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            tahitiangabriel Gabriel Landon
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: