You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alfredo Aleandri <al...@logobject.ch> on 2009/04/23 17:35:16 UTC

datatable columns shuffle

Hi,
I'm a wicket beginner.
I'm trying to shuffle the columns of a datatable using an 
AjaxFallbackLink, this is my code (only relevant part):

my WebPage content:

    private AjaxFallbackDefaultDataTable usersTable;
    private List<IColumn<?>> userColumns = new ArrayList<IColumn<?>>();
    private UserProvider userProvider = new UserProvider();

    public QueryPage() {
       
        userColumns.add(new PropertyColumn(new Model<String>("First 
Name"), "FIRSTNAME", "firstName"));
        userColumns.add(new PropertyColumn(new Model<String>("Last 
Name"), "LASTNAME", "lastName"));
        usersTable = new AjaxFallbackDefaultDataTable("users_table", 
userColumns, userProvider, 20);
        usersTable.setOutputMarkupId(true);
        add(usersTable);
       
        add(new AjaxFallbackLink("users_shuffle") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                Collections.shuffle(userColumns);
                usersTable = new 
AjaxFallbackDefaultDataTable("users_table", userColumns, userProvider, 20);
                if (target != null) {
                    target.addComponent(usersTable);
                }
            }
        });

    }

my html page content:

    <a wicket:id="users_shuffle" href="#">Shuffle!</a>
    <table wicket:id="users_table">[table]</table>


When I click the ajax link the "onClick" is executed, the userColumns 
list is shuffled but the page rendering is always the same as defined in 
the constructor of the WebPage.
I've tryied also using a standard Link (no ajax) getting the same result.
I'm using Wicket 1.4rc2.

Thank you

Alfredo


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


Re: datatable columns shuffle

Posted by "alf.redo" <al...@logobject.ch>.

igor.vaynberg wrote:
> 
> you need to call replace(userstable) so that your new instance gets
> put into the component hierarchy.
> 

Thank you Igor,
I've solved. I post the relevant part of the code that do the trick:



        add(new AjaxFallbackLink("users_shuffle") {
            @Override
            public void onClick(AjaxRequestTarget target) {
                Collections.shuffle(userColumns);
                usersTable = new AjaxFallbackDefaultDataTable("users_table",
userColumns, userProvider, 20); 
                getParent().replace(usersTable);
                if (target != null) {
                    target.addComponent(usersTable);
                }                
            }
        });



-- 
View this message in context: http://www.nabble.com/datatable-columns-shuffle-tp23199789p23213845.html
Sent from the Wicket - User mailing list archive at Nabble.com.

Re: datatable columns shuffle

Posted by Igor Vaynberg <ig...@gmail.com>.
you need to call replace(userstable) so that your new instance gets
put into the component hierarchy.

-igor

On Fri, Apr 24, 2009 at 1:19 AM, alf.redo <al...@logobject.ch> wrote:
>
>
> igor.vaynberg wrote:
>>
>> datatable does not support changing columns, something on a todo list
>> to fix in 1.5. for now you can just recreate the datatable itself.
>>
>
> Hi Igor,
> thank you for the answer.
> In my code I recreate the datatable in the AjaxFallbackLink#onClick method,
> as you can see in my starting topic. What is the mistake?
>
> Thank you again...
>
> alf
>
> --
> View this message in context: http://www.nabble.com/datatable-columns-shuffle-tp23199789p23211966.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
>
>

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


Re: datatable columns shuffle

Posted by "alf.redo" <al...@logobject.ch>.

igor.vaynberg wrote:
> 
> datatable does not support changing columns, something on a todo list
> to fix in 1.5. for now you can just recreate the datatable itself.
> 

Hi Igor,
thank you for the answer.
In my code I recreate the datatable in the AjaxFallbackLink#onClick method,
as you can see in my starting topic. What is the mistake?

Thank you again...

alf

-- 
View this message in context: http://www.nabble.com/datatable-columns-shuffle-tp23199789p23211966.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: datatable columns shuffle

Posted by Igor Vaynberg <ig...@gmail.com>.
datatable does not support changing columns, something on a todo list
to fix in 1.5. for now you can just recreate the datatable itself.

-igor

On Thu, Apr 23, 2009 at 8:35 AM, Alfredo Aleandri
<al...@logobject.ch> wrote:
> Hi,
> I'm a wicket beginner.
> I'm trying to shuffle the columns of a datatable using an AjaxFallbackLink,
> this is my code (only relevant part):
>
> my WebPage content:
>
>   private AjaxFallbackDefaultDataTable usersTable;
>   private List<IColumn<?>> userColumns = new ArrayList<IColumn<?>>();
>   private UserProvider userProvider = new UserProvider();
>
>   public QueryPage() {
>             userColumns.add(new PropertyColumn(new Model<String>("First
> Name"), "FIRSTNAME", "firstName"));
>       userColumns.add(new PropertyColumn(new Model<String>("Last Name"),
> "LASTNAME", "lastName"));
>       usersTable = new AjaxFallbackDefaultDataTable("users_table",
> userColumns, userProvider, 20);
>       usersTable.setOutputMarkupId(true);
>       add(usersTable);
>             add(new AjaxFallbackLink("users_shuffle") {
>           @Override
>           public void onClick(AjaxRequestTarget target) {
>               Collections.shuffle(userColumns);
>               usersTable = new AjaxFallbackDefaultDataTable("users_table",
> userColumns, userProvider, 20);
>               if (target != null) {
>                   target.addComponent(usersTable);
>               }
>           }
>       });
>
>   }
>
> my html page content:
>
>   <a wicket:id="users_shuffle" href="#">Shuffle!</a>
>   <table wicket:id="users_table">[table]</table>
>
>
> When I click the ajax link the "onClick" is executed, the userColumns list
> is shuffled but the page rendering is always the same as defined in the
> constructor of the WebPage.
> I've tryied also using a standard Link (no ajax) getting the same result.
> I'm using Wicket 1.4rc2.
>
> Thank you
>
> Alfredo
>
>
> ---------------------------------------------------------------------
> 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