thanks,
That's what I thought. I just wasn't sure...
On Wed, Mar 26, 2008 at 6:07 PM, Igor Vaynberg <[EMAIL PROTECTED]>
wrote:
> override oncomponenttag and add the class there dynamically instead of
> using an attribute modifier
>
> -igor
>
>
> On Wed, Mar 26, 2008 at 5:23 AM, Eyal Golan <[EMAIL PROTECTED]> wrote:
> > Hi,
> > I have a DataTable that I want to add to it a class name in a specific
> > situation.
> > Otherwise, I want to remove it.
> >
> > Here's the class:
> > package com....;
> >
> > import org.apache.wicket.behavior.AttributeAppender;
> > import org.apache.wicket.behavior.HeaderContributor;
> > import
> > org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
> > import
> org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
> > import
> >
> org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider
> > ;
> > import
> >
> org.apache.wicket.extensions.markup.html.repeater.data.table.NavigationToolbar
> > ;
> > import
> >
> org.apache.wicket.extensions.markup.html.repeater.data.table.NoRecordsToolbar
> > ;
> > import org.apache.wicket.markup.ComponentTag;
> > import org.apache.wicket.markup.MarkupStream;
> > import org.apache.wicket.markup.repeater.Item;
> > import org.apache.wicket.model.IModel;
> > import org.apache.wicket.model.Model;
> >
> > public class MyDataTable extends DataTable {
> > private static final long serialVersionUID = -8952247313105963726L;
> >
> > public MyDataTable(String id, IColumn[] columns,
> ISortableDataProvider
> > dataProvider,
> > int rowsPerPage) {
> > super(id, columns, dataProvider, rowsPerPage);
> > add(HeaderContributor.forCss("/.../style/MyDataTable.css"));
> > // add(new SimpleAttributeModifier("rules", "all"));
> > add(new AttributeAppender("class", true, new Model("myTable"), "
> > "));
> > addTopToolbar(new NavigationToolbar(this));
> > addTopToolbar(new MyHeadersToolbar(this, dataProvider));
> > addBottomToolbar(new NoRecordsToolbar(this));
> > *if (dataProvider.size() == 0) {
> > add(new AttributeAppender("class", true, new
> > Model("emptyTable"), " "));
> > } else {
> > //Here I want to remove the 'emptyTable' class.
> > // MarkupStream markupStream =
> getAssociatedMarkupStream(false);
> > }*
> >
> > }
> >
> > @Override
> > protected void onComponentTag(ComponentTag tag) {
> > super.onComponentTag(tag);
> >
> > }
> >
> > @Override
> > protected Item newRowItem(final String id, int index, final IModel
> > model) {
> > Item item = new Item(id, index, model);
> > item.add(new AttributeAppender("class", true, new Model(index %
> 2 ==
> > 0 ? "odd"
> > : "even"), " "));
> > return item;
> > }
> > }
> >
> > Any suggetsions?
> >
> > --
> > Eyal Golan
> > [EMAIL PROTECTED]
> >
> > Visit: http://jvdrums.sourceforge.net/
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Eyal Golan
[EMAIL PROTECTED]
Visit: http://jvdrums.sourceforge.net/