You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by PSkarthic <ka...@touchpointindia.com> on 2009/01/23 09:42:17 UTC
Pagination in wicket
Hi
I worked on wicket for a month only, i want pagination to be done in
wicket.
Can anybody guide me or provide some samples, it would be big help for me.
I have tried googling "Pagination in wicket" but not yet get the solution.
I have also tried Pagenavigator but don't know how to use it correctly(Stuck
in creating the dataview
Thanks in advance
Karthic
--
View this message in context: http://www.nabble.com/Pagination-in-wicket-tp21620591p21620591.html
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: Pagination in wicket
Posted by K <ko...@gmail.com>.
Hey Jesse
Thanks for the response... it works well
-----
K
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Pagination-in-wicket-tp1878842p4666412.html
Sent from the Users forum 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: Pagination in wicket
Posted by Jesse Long <jp...@unknown.za.net>.
Oh, yes and...
response.render(new OnDomReadyHeaderItem("$('#" +
pageNumberTextFieldId + "').keydown(function(event){if (event.which ==
13){event.preventDefault();$(this).blur();}});"));
response.render(new OnDomReadyHeaderItem("$('#" +
pageNumberTextFieldId + "').focus(function(){$(this).select();});"));
in renderHead()
Cheers,
Jesse
On 27/06/2014 14:06, Jesse Long wrote:
> Hi K,
>
> I use this:
>
>
> <div class="btn-group">
> <a wicket:id="firstPageLink"
> class="btn btn-default"><span class="glyphicon
> glyphicon-fast-backward"></span></a>
> <a wicket:id="previousPageLink"
> class="btn btn-default"><span class="glyphicon
> glyphicon-backward"></span></a>
> </div>
> Page <input type="text"
> wicket:id="pageNumberInput" style="margin: 0px; width: 45px;
> text-align: right; padding: 0px 4px; display: inline-block;"
> class="form-control"/>
> of <span wicket:id="numberOfPages"></span>
> <div class="btn-group">
> <a wicket:id="nextPageLink" class="btn
> btn-default"><span class="glyphicon glyphicon-forward"></span></a>
> <a wicket:id="lastPageLink" class="btn
> btn-default"><span class="glyphicon glyphicon-fast-forward"></span></a>
> </div>
>
>
>
>
> final TextField<Long> pageNumberTextField = new
> TextField<Long>("pageNumberInput", new IModel<Long>()
> {
> @Override
> public Long getObject()
> {
> return dataTable.getCurrentPage() + 1;
> }
>
> @Override
> public void setObject(Long object)
> {
> if (object != null){
> long v = object - 1;
> if (v > dataTable.getPageCount() - 1){
> v = dataTable.getPageCount() - 1;
> }else if (v < 0){
> v = 0;
> }
> setCurrentPage(v);
> }
> }
>
> @Override
> public void detach()
> {
> }
> }, Long.class)
> {
> @Override
> protected void onConfigure()
> {
> super.onConfigure();
>
> clearInput();
> }
> };
>
> pageNumberTextField.add(new
> AjaxFormComponentUpdatingBehavior("change")
> {
> @Override
> protected void onError(AjaxRequestTarget target,
> RuntimeException e)
> {
> pageNumberTextField.clearInput();
> target.add(pageNumberTextField);
> target.focusComponent(pageNumberTextField);
> }
>
> @Override
> protected void onUpdate(AjaxRequestTarget target)
> {
> target.add(container); // container including
> navigation as well as data table
> target.focusComponent(pageNumberTextField);
> }
> });
>
> pageNumberTextField.setOutputMarkupId(true);
> add(pageNumberTextField);
>
> add(new AjaxFallbackLink<Void>("firstPageLink")
> {
> @Override
> public void onClick(AjaxRequestTarget target)
> {
> setCurrentPage(0);
> if (target != null){
> target.add(container); // container including nav
> and data table
> }
> }
>
> @Override
> protected void onConfigure()
> {
> super.onConfigure();
>
> setEnabled(dataTable.getCurrentPage() > 0);
> }
> });
>
> add(new AjaxFallbackLink<Void>("previousPageLink")
> {
> @Override
> public void onClick(AjaxRequestTarget target)
> {
> long currentPage = dataTable.getCurrentPage();
>
> if (currentPage > 0){
> setCurrentPage(currentPage - 1);
> }
>
> if (target != null){
> target.add(container); // container including nav
> and data table
> }
> }
>
> @Override
> protected void onConfigure()
> {
> super.onConfigure();
>
> setEnabled(dataTable.getCurrentPage() > 0);
> }
> });
>
> add(new AjaxFallbackLink<Void>("nextPageLink")
> {
> @Override
> public void onClick(AjaxRequestTarget target)
> {
> long currentPage = dataTable.getCurrentPage();
>
> if (currentPage < dataTable.getPageCount() - 1){
> setCurrentPage(currentPage + 1);
> }
>
> if (target != null){
> target.add(container); // container including nav
> and data table
> }
> }
>
> @Override
> protected void onConfigure()
> {
> super.onConfigure();
>
> setEnabled(dataTable.getCurrentPage() <
> dataTable.getPageCount() - 1);
> }
> });
>
> add(new AjaxFallbackLink<Void>("lastPageLink")
> {
> @Override
> public void onClick(AjaxRequestTarget target)
> {
> setCurrentPage(dataTable.getPageCount() - 1);
>
> if (target != null){
> target.add(container); // container including nav
> and data table
> }
> }
>
> @Override
> protected void onConfigure()
> {
> super.onConfigure();
>
> setEnabled(dataTable.getCurrentPage() <
> dataTable.getPageCount() - 1);
> }
> });
>
> add(new Label("numberOfPages", new AbstractReadOnlyModel<Long>()
> {
> @Override
> public Long getObject()
> {
> return dataTable.getPageCount();
> }
> });
>
>
> This is bootstrap 3 pretty much does what you are asking. I dont
> implement this as a data table toolbar, but rather directly below the
> data table (my data table is wrapped in overflow-x: auto).
>
> Cheers,
> Jesse
>
>
>
> On 27/06/2014 12:58, K wrote:
>> Hey there
>>
>> i have been trying to trying to implement something like
>>
>> << < (textbox) of (totalnumberofpages) > >>
>>
>> any suggestions on this
>>
>> Thanks in advance...
>>
>> -----
>>
>> K
>> --
>> View this message in context:
>> http://apache-wicket.1842946.n4.nabble.com/Pagination-in-wicket-tp1878842p4666398.html
>> Sent from the Users forum 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Pagination in wicket
Posted by Jesse Long <jp...@unknown.za.net>.
Hi K,
I use this:
<div class="btn-group">
<a wicket:id="firstPageLink" class="btn
btn-default"><span class="glyphicon glyphicon-fast-backward"></span></a>
<a wicket:id="previousPageLink"
class="btn btn-default"><span class="glyphicon
glyphicon-backward"></span></a>
</div>
Page <input type="text"
wicket:id="pageNumberInput" style="margin: 0px; width: 45px; text-align:
right; padding: 0px 4px; display: inline-block;" class="form-control"/>
of <span wicket:id="numberOfPages"></span>
<div class="btn-group">
<a wicket:id="nextPageLink" class="btn
btn-default"><span class="glyphicon glyphicon-forward"></span></a>
<a wicket:id="lastPageLink" class="btn
btn-default"><span class="glyphicon glyphicon-fast-forward"></span></a>
</div>
final TextField<Long> pageNumberTextField = new
TextField<Long>("pageNumberInput", new IModel<Long>()
{
@Override
public Long getObject()
{
return dataTable.getCurrentPage() + 1;
}
@Override
public void setObject(Long object)
{
if (object != null){
long v = object - 1;
if (v > dataTable.getPageCount() - 1){
v = dataTable.getPageCount() - 1;
}else if (v < 0){
v = 0;
}
setCurrentPage(v);
}
}
@Override
public void detach()
{
}
}, Long.class)
{
@Override
protected void onConfigure()
{
super.onConfigure();
clearInput();
}
};
pageNumberTextField.add(new
AjaxFormComponentUpdatingBehavior("change")
{
@Override
protected void onError(AjaxRequestTarget target,
RuntimeException e)
{
pageNumberTextField.clearInput();
target.add(pageNumberTextField);
target.focusComponent(pageNumberTextField);
}
@Override
protected void onUpdate(AjaxRequestTarget target)
{
target.add(container); // container including
navigation as well as data table
target.focusComponent(pageNumberTextField);
}
});
pageNumberTextField.setOutputMarkupId(true);
add(pageNumberTextField);
add(new AjaxFallbackLink<Void>("firstPageLink")
{
@Override
public void onClick(AjaxRequestTarget target)
{
setCurrentPage(0);
if (target != null){
target.add(container); // container including nav
and data table
}
}
@Override
protected void onConfigure()
{
super.onConfigure();
setEnabled(dataTable.getCurrentPage() > 0);
}
});
add(new AjaxFallbackLink<Void>("previousPageLink")
{
@Override
public void onClick(AjaxRequestTarget target)
{
long currentPage = dataTable.getCurrentPage();
if (currentPage > 0){
setCurrentPage(currentPage - 1);
}
if (target != null){
target.add(container); // container including nav
and data table
}
}
@Override
protected void onConfigure()
{
super.onConfigure();
setEnabled(dataTable.getCurrentPage() > 0);
}
});
add(new AjaxFallbackLink<Void>("nextPageLink")
{
@Override
public void onClick(AjaxRequestTarget target)
{
long currentPage = dataTable.getCurrentPage();
if (currentPage < dataTable.getPageCount() - 1){
setCurrentPage(currentPage + 1);
}
if (target != null){
target.add(container); // container including nav
and data table
}
}
@Override
protected void onConfigure()
{
super.onConfigure();
setEnabled(dataTable.getCurrentPage() <
dataTable.getPageCount() - 1);
}
});
add(new AjaxFallbackLink<Void>("lastPageLink")
{
@Override
public void onClick(AjaxRequestTarget target)
{
setCurrentPage(dataTable.getPageCount() - 1);
if (target != null){
target.add(container); // container including nav
and data table
}
}
@Override
protected void onConfigure()
{
super.onConfigure();
setEnabled(dataTable.getCurrentPage() <
dataTable.getPageCount() - 1);
}
});
add(new Label("numberOfPages", new AbstractReadOnlyModel<Long>()
{
@Override
public Long getObject()
{
return dataTable.getPageCount();
}
});
This is bootstrap 3 pretty much does what you are asking. I dont
implement this as a data table toolbar, but rather directly below the
data table (my data table is wrapped in overflow-x: auto).
Cheers,
Jesse
On 27/06/2014 12:58, K wrote:
> Hey there
>
> i have been trying to trying to implement something like
>
> << < (textbox) of (totalnumberofpages) > >>
>
> any suggestions on this
>
> Thanks in advance...
>
> -----
>
> K
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Pagination-in-wicket-tp1878842p4666398.html
> Sent from the Users forum 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: Pagination in wicket
Posted by K <ko...@gmail.com>.
Hey there
i have been trying to trying to implement something like
<< < (textbox) of (totalnumberofpages) > >>
any suggestions on this
Thanks in advance...
-----
K
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Pagination-in-wicket-tp1878842p4666398.html
Sent from the Users forum 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: Pagination in wicket
Posted by Michael O'Cleirigh <mi...@rivulet.ca>.
You can also check out this wiki page:
http://cwiki.apache.org/WICKET/simple-sortable-datatable-example.html
Basically the DefaultDatatable takes:
1. an array of TableColumn extending classes that are used to build the
cell component and connect the row object (typically each column would
be connected to a field in the row object).
2. an IDataProvider implementation which provides the table row data.
Within it you provide the total number of elements/rows and an iterator
containg a specific page.
3. the number of rows per page.
The DefaultDataTable has built in support for pagination (i.e. it adds
in a set of default top and bottom toolbars) If you look in the
constructor you can see what I mean.
The last example in the wicketstuff.org example Michael referenced shows
what this looks like.
Regards,
Mike
> Check out the wicket examples (especially those on repeaters on
> http://www.wicketstuff.org/wicket13/repeater/) - they'll help you getting
> started
>
> regards,
> Michael
>
>
>
> PSkarthic wrote:
>
>> Hi
>> I worked on wicket for a month only, i want pagination to be done in
>> wicket.
>> Can anybody guide me or provide some samples, it would be big help for me.
>>
>> I have tried googling "Pagination in wicket" but not yet get the
>> solution.
>>
>> I have also tried Pagenavigator but don't know how to use it
>> correctly(Stuck in creating the dataview
>>
>>
>> Thanks in advance
>> Karthic
>>
>>
>
>
> -----
> Michael Sparer
> http://talk-on-tech.blogspot.com
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Pagination in wicket
Posted by Michael Sparer <mi...@gmx.at>.
Check out the wicket examples (especially those on repeaters on
http://www.wicketstuff.org/wicket13/repeater/) - they'll help you getting
started
regards,
Michael
PSkarthic wrote:
>
> Hi
> I worked on wicket for a month only, i want pagination to be done in
> wicket.
> Can anybody guide me or provide some samples, it would be big help for me.
>
> I have tried googling "Pagination in wicket" but not yet get the
> solution.
>
> I have also tried Pagenavigator but don't know how to use it
> correctly(Stuck in creating the dataview
>
>
> Thanks in advance
> Karthic
>
-----
Michael Sparer
http://talk-on-tech.blogspot.com
--
View this message in context: http://www.nabble.com/Pagination-in-wicket-tp21620591p21620701.html
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