Reputation: 4614
I am usign GWT2.3. We developed CustomPager by overriding SimplePager.
We override createText() method such a way that we are showing string like "Page 1 of 4" using following code
public String createText() {
if(searchRecordCount%pageSizeForText == 0){
totalPages = searchRecordCount/pageSizeForText;
}else{
totalPages = (searchRecordCount/pageSizeForText) + 1;
}
NumberFormat formatter = NumberFormat.getFormat("#,###");
return "Page "+formatter.format(this.getPage()+1) + " of " + formatter.format(totalPages);
}
Now I want to use TextBox for CurrentPage so that user can enter page Number in textBox. (Functionality GoTo entered pageNumber)
createText() returns string so I cant user textBox ;) + Can't provide css
How can I do this ? Is there any way to solve this problem? Workaround if any or Sample code
Upvotes: 2
Views: 1351
Reputation: 17499
There are two ways how to achieve this:
1.) Use HTML code to create a TextBox:
In the createText()
function you can create the textbox manually by using HTML code (better use SafeHTML templates for avoiding XSS):
String textbox_str = "<input type='textbox' name='goto'>";
However you have to write code for handling the actual event (i.e. ChangeEvent) and call setPage()
of your SimplePager using JSNI.
2.) Add TextBox widget to SimplePager and override constructor:
SimplePager is basically a Composite which adds ImageButtons in its constructor for the forward and backward links.
You can extend SimplePager add a TextBox and override the constructor to add the TextBox between the forward and backward ImageButtons.
Upvotes: 3