You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Jan Kriesten <ja...@renitence.de> on 2007/10/13 13:59:22 UTC

RFE: DataTable && colgroup

[https://issues.apache.org/jira/browse/WICKET-1069]

Hi!

I want to suggest an enhancement for the DataTable extension.

Right now it's only possible to style columns (width, alignment, color etc.) via
stylesheets. This has some not so nice implications IMHO:

- You have to extend the IStyledColumn to return the proper CSS class.
- You have to add a bunch of CSS classes to get the proper styles.
- You have redundancy in HTML output - which isn't necessary.

This is actually what <colgroup><col></colgroup> is meant to solve.

My suggestion:

Adding a 'addColGroup( ColGroup cg )'-feature, which actually lets you add x
ColGroups with n Cols on which you can use AttributeModifiers to have your
styles/classes/width-Attributes added.

A quick implementation would be this:

---[ColGroup.java]--
import java.util.List;

import org.apache.wicket.behavior.IBehavior;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractToolbar;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.repeater.RepeatingView;

public class ColGroup
    extends AbstractToolbar
{
  private static final long serialVersionUID = 1L;

  private int numCols;
  private Col[] cols;

  public ColGroup( DataTable datatable, int numCols )
  {
    super( datatable );
    this.numCols = numCols;
  }

  public void onBeforeRender()
  {
    if( !hasBeenRendered() )
    {
      WebMarkupContainer colgroup = new WebMarkupContainer( "colgroup" );
      for( IBehavior b : (List<IBehavior>) getBehaviors() )
        colgroup.add( b );
      setRenderBodyOnly( true );
      removeAll();
      add( colgroup );

      RepeatingView colgroupCols = new RepeatingView( "elements" );
      colgroup.add( colgroupCols );

      for( Col column : getCols() )
      {
        WebMarkupContainer item = new WebMarkupContainer(
colgroupCols.newChildId() );
        colgroupCols.add( item );
        item.add( column );
      }

    }
    super.onBeforeRender();
  }

  public final Col[] getCols( )
  {
    if( cols == null )
    {
      cols = new Col[numCols];
      for( int i = 0; i < numCols; i++ )
        cols[i] = new Col();
    }
    return(cols);
  }

  public final class Col
      extends WebMarkupContainer
  {
    private static final long serialVersionUID = 1L;

    private Col()
    {
      super( "col" );
    }
  }

}
---[/ColGroup.java]--

---[ColGroup.html]--
  <wicket:panel>
    <colgroup wicket:id="colgroup">
      <wicket:container wicket:id="elements"><col
wicket:id="col"/></wicket:container>
    </colgroup>
  </wicket:panel>
---[/ColGroup.html]--


Usage:

ColGroup colgroup = new ColGroup( datatable, 4 );
colgroup.add( new SimpleAttributeModifier( "style", "border: solid 1px green;" ) );
Col[] cols = colgroup.getCols();
cols[0].add( new SimpleAttributeModifier( "width", "10%" ) );
cols[1].add( new SimpleAttributeModifier( "width", "35%" ) );
cols[2].add( new SimpleAttributeModifier( "width", "45%" ) );
cols[3].add( new SimpleAttributeModifier( "width", "10%" ) );
datatable.addColGroup( colgroup );


Any thoughts?

Regards, --- Jan.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RFE: DataTable && colgroup

Posted by Matej Knopp <ma...@gmail.com>.
We might add this to Wicket, can you please open a RFE and attach the
appropriate classes?

Thanks..
-Matej

On 10/14/07, Kent Tong <ke...@cpttm.org.mo> wrote:
>
>
> Jan Kriesten wrote:
> >
> > might be, but it's a nice feature for just styling col-width and
> > col-alignment.
> > actually, this would be an optional add-on, no replacement for
> > IStyledColumn.
> >
> > since it is pretty easy to implement, what are the pitfalls when have it
> > added?
> >
>
> All mozilla-based browsers don't support it due to an alleged contradiction
> between
> HTML4 and CSS (see https://bugzilla.mozilla.org/show_bug.cgi?id=915#c27).
>
>
> -----
> --
> Kent Tong
> Wicket tutorials freely available at http://www.agileskills2.org/EWDW
> --
> View this message in context: http://www.nabble.com/RFE%3A-DataTable----colgroup-tf4618089.html#a13196020
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RFE: DataTable && colgroup

Posted by Kent Tong <ke...@cpttm.org.mo>.

Jan Kriesten wrote:
> 
> might be, but it's a nice feature for just styling col-width and
> col-alignment.
> actually, this would be an optional add-on, no replacement for
> IStyledColumn.
> 
> since it is pretty easy to implement, what are the pitfalls when have it
> added?
> 

All mozilla-based browsers don't support it due to an alleged contradiction
between 
HTML4 and CSS (see https://bugzilla.mozilla.org/show_bug.cgi?id=915#c27).


-----
--
Kent Tong
Wicket tutorials freely available at http://www.agileskills2.org/EWDW
-- 
View this message in context: http://www.nabble.com/RFE%3A-DataTable----colgroup-tf4618089.html#a13196020
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RFE: DataTable && colgroup

Posted by Jan Kriesten <ja...@renitence.de>.
hi matej,

> I was thinking of implementing colgroup support, but I decided not to.
> Colgroup as far as i can tell has serious styling limitation, which
> only allows to specify very reduced subset of css to the colgroup.

might be, but it's a nice feature for just styling col-width and col-alignment.
actually, this would be an optional add-on, no replacement for IStyledColumn.

since it is pretty easy to implement, what are the pitfalls when have it added?

best regards, --- jan.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: RFE: DataTable && colgroup

Posted by Matej Knopp <ma...@gmail.com>.
I was thinking of implementing colgroup support, but I decided not to.
Colgroup as far as i can tell has serious styling limitation, which
only allows to specify very reduced subset of css to the colgroup.

-Matej

On 10/13/07, Jan Kriesten <ja...@renitence.de> wrote:
>
> [https://issues.apache.org/jira/browse/WICKET-1069]
>
> Hi!
>
> I want to suggest an enhancement for the DataTable extension.
>
> Right now it's only possible to style columns (width, alignment, color etc.) via
> stylesheets. This has some not so nice implications IMHO:
>
> - You have to extend the IStyledColumn to return the proper CSS class.
> - You have to add a bunch of CSS classes to get the proper styles.
> - You have redundancy in HTML output - which isn't necessary.
>
> This is actually what <colgroup><col></colgroup> is meant to solve.
>
> My suggestion:
>
> Adding a 'addColGroup( ColGroup cg )'-feature, which actually lets you add x
> ColGroups with n Cols on which you can use AttributeModifiers to have your
> styles/classes/width-Attributes added.
>
> A quick implementation would be this:
>
> ---[ColGroup.java]--
> import java.util.List;
>
> import org.apache.wicket.behavior.IBehavior;
> import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractToolbar;
> import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
> import org.apache.wicket.markup.html.WebMarkupContainer;
> import org.apache.wicket.markup.repeater.RepeatingView;
>
> public class ColGroup
>     extends AbstractToolbar
> {
>   private static final long serialVersionUID = 1L;
>
>   private int numCols;
>   private Col[] cols;
>
>   public ColGroup( DataTable datatable, int numCols )
>   {
>     super( datatable );
>     this.numCols = numCols;
>   }
>
>   public void onBeforeRender()
>   {
>     if( !hasBeenRendered() )
>     {
>       WebMarkupContainer colgroup = new WebMarkupContainer( "colgroup" );
>       for( IBehavior b : (List<IBehavior>) getBehaviors() )
>         colgroup.add( b );
>       setRenderBodyOnly( true );
>       removeAll();
>       add( colgroup );
>
>       RepeatingView colgroupCols = new RepeatingView( "elements" );
>       colgroup.add( colgroupCols );
>
>       for( Col column : getCols() )
>       {
>         WebMarkupContainer item = new WebMarkupContainer(
> colgroupCols.newChildId() );
>         colgroupCols.add( item );
>         item.add( column );
>       }
>
>     }
>     super.onBeforeRender();
>   }
>
>   public final Col[] getCols( )
>   {
>     if( cols == null )
>     {
>       cols = new Col[numCols];
>       for( int i = 0; i < numCols; i++ )
>         cols[i] = new Col();
>     }
>     return(cols);
>   }
>
>   public final class Col
>       extends WebMarkupContainer
>   {
>     private static final long serialVersionUID = 1L;
>
>     private Col()
>     {
>       super( "col" );
>     }
>   }
>
> }
> ---[/ColGroup.java]--
>
> ---[ColGroup.html]--
>   <wicket:panel>
>     <colgroup wicket:id="colgroup">
>       <wicket:container wicket:id="elements"><col
> wicket:id="col"/></wicket:container>
>     </colgroup>
>   </wicket:panel>
> ---[/ColGroup.html]--
>
>
> Usage:
>
> ColGroup colgroup = new ColGroup( datatable, 4 );
> colgroup.add( new SimpleAttributeModifier( "style", "border: solid 1px green;" ) );
> Col[] cols = colgroup.getCols();
> cols[0].add( new SimpleAttributeModifier( "width", "10%" ) );
> cols[1].add( new SimpleAttributeModifier( "width", "35%" ) );
> cols[2].add( new SimpleAttributeModifier( "width", "45%" ) );
> cols[3].add( new SimpleAttributeModifier( "width", "10%" ) );
> datatable.addColGroup( colgroup );
>
>
> Any thoughts?
>
> Regards, --- Jan.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org