StackOverFlow
StackOverFlow

Reputation: 4614

GWT SimplePager: How to provide tooltip on pagers button like first, last, next, previous?

I am using Custom Pager by extending Simple Pager. GWT version is 2.3

I want to provide tool-tip on SimplePagers button like first, last, next, previous.

How can I achieve this ?

Any help or guidance in this matter would be appreciated.

Upvotes: 3

Views: 528

Answers (1)

Chris Lercher
Chris Lercher

Reputation: 37778

This is actually not so easy to do, because SimplePager is not a very extendable class. It doesn't provide access to its private button fields in any way, and it also doesn't assign unique style classes to each of them.

One solution you could use is:

final NodeList<Element> tdElems = 
    simplePager.getElement().getElementsByTagName("td");

for (int i = 0; i < tdElems.getLength(); i++) {

  final String toolTipText;

  if (i == 0)
    toolTipText = "First page";
  else if (i == 1)
    toolTipText = "Previous page";
  else if (i == 2)
    continue; /* This is the middle td - no button */
  else if (i == 3)
    toolTipText = "Next page";
  else if (i == 4)
    toolTipText = "Last page";
  else
    continue;

  tdElems.getItem(i).setTitle(toolTipText);
}

But honestly, this is not a very solid approach - it breaks if the layout of SimplePager changes in the future. I'd rather re-implement SimplePager, and access the button fields directly.

Upvotes: 2

Related Questions