You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Steve Swinsburg <st...@gmail.com> on 2015/06/18 14:15:41 UTC

Making a datatable more accessible

Hi all,

I have a datatable and need to make it more accessible for screenreaders.

I am using an AbstractColumn and setting the getHeader and populateItem
methods with the contents.

In a particular row I want to change the markup of the cells from TD to TH,
as they are header type content. Is this possible in Wicket, to change the
HTML tag? This is generated markup within the DataTable component so I'm
wondering if we can influence the HTML tag that is output.

The second issue is that when using getHeader to set the header cell
contents, it outputs this into a span within the TH, not directly within
the TH itself. I need to add the 'scope="col"' ARIA attribute to the TH but
cannot access it (even via getParent()). Again, generated markup.

Thanks for any assistance.

regards,
Steve

Re: Making a datatable more accessible

Posted by Steve Swinsburg <st...@gmail.com>.
Thanks very much, I'll give it a try.

sent from my mobile device
On 19 Jun 2015 4:34 am, "Sven Meier" <sv...@meiers.net> wrote:

> Hi,
>
> it's a little bit finicky, but it can be done:
>
>         DataTable dataTable = new DefaultDataTable<Contact,
> String>("table", columns, new SortableContactDataProvider(), 8) {
>             protected Item<IColumn<Contact, String>> newCellItem(final
> String id, final int index, final IModel<IColumn<Contact, String>> model)
>             {
>                     return new Item<IColumn<Contact, String>>(id, index,
> model) {
>                         @Override
>                         protected void onComponentTag(ComponentTag tag) {
>                             super.onComponentTag(tag);
>
>                             // parent is the repeater for the cells, its
> parent is the row
>                             Contact contact = (Contact)
> getParent().getParent().getDefaultModelObject();
>                             if (contact.isSpecĂ­al()) {
>                                 tag.setName("th");
>                             }
>                         }
>                     };
>                 }
>         };
>
> In a future version we might want to change #newCellItem() to get a
> reference to the row's model - that would remove the need to lookup the row
> object from the  grandparent.
>
> Have fun
> Sven
>
>
> On 18.06.2015 14:15, Steve Swinsburg wrote:
>
>> Hi all,
>>
>> I have a datatable and need to make it more accessible for screenreaders.
>>
>> I am using an AbstractColumn and setting the getHeader and populateItem
>> methods with the contents.
>>
>> In a particular row I want to change the markup of the cells from TD to
>> TH,
>> as they are header type content. Is this possible in Wicket, to change the
>> HTML tag? This is generated markup within the DataTable component so I'm
>> wondering if we can influence the HTML tag that is output.
>>
>> The second issue is that when using getHeader to set the header cell
>> contents, it outputs this into a span within the TH, not directly within
>> the TH itself. I need to add the 'scope="col"' ARIA attribute to the TH
>> but
>> cannot access it (even via getParent()). Again, generated markup.
>>
>> Thanks for any assistance.
>>
>> regards,
>> Steve
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Making a datatable more accessible

Posted by Sven Meier <sv...@meiers.net>.
Hi,

it's a little bit finicky, but it can be done:

         DataTable dataTable = new DefaultDataTable<Contact, 
String>("table", columns, new SortableContactDataProvider(), 8) {
             protected Item<IColumn<Contact, String>> newCellItem(final 
String id, final int index, final IModel<IColumn<Contact, String>> model)
             {
                     return new Item<IColumn<Contact, String>>(id, 
index, model) {
                         @Override
                         protected void onComponentTag(ComponentTag tag) {
                             super.onComponentTag(tag);

                             // parent is the repeater for the cells, 
its parent is the row
                             Contact contact = (Contact) 
getParent().getParent().getDefaultModelObject();
                             if (contact.isSpecĂ­al()) {
                                 tag.setName("th");
                             }
                         }
                     };
                 }
         };

In a future version we might want to change #newCellItem() to get a 
reference to the row's model - that would remove the need to lookup the 
row object from the  grandparent.

Have fun
Sven


On 18.06.2015 14:15, Steve Swinsburg wrote:
> Hi all,
>
> I have a datatable and need to make it more accessible for screenreaders.
>
> I am using an AbstractColumn and setting the getHeader and populateItem
> methods with the contents.
>
> In a particular row I want to change the markup of the cells from TD to TH,
> as they are header type content. Is this possible in Wicket, to change the
> HTML tag? This is generated markup within the DataTable component so I'm
> wondering if we can influence the HTML tag that is output.
>
> The second issue is that when using getHeader to set the header cell
> contents, it outputs this into a span within the TH, not directly within
> the TH itself. I need to add the 'scope="col"' ARIA attribute to the TH but
> cannot access it (even via getParent()). Again, generated markup.
>
> Thanks for any assistance.
>
> regards,
> Steve
>


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