Sorted properties

0 views
Skip to first unread message

Fer

unread,
Apr 23, 2009, 4:52:40 PM4/23/09
to Wicket Web Beans
In the wwb table, the primitive properties appearas as non-sorteable
columns.
¿How can i fix that?

Example:

public class Dog implements Serializable {

private static final long serialVersionUID = 1L;

private String name;

private int age;

public String getName() {
return name;
}

public void setName(final String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(final int age) {
this.age = age;
}

}

....Some Wicket component
List<Dog> dogs = new LinkedList<Dog>();
dogs.add(new Dog("Juan", 12));
dogs.add(new Dog("Pedro", 15));
BeanMetaData meta = new BeanMetaData(Dog.class, null, this,
null, true);
add(new BeanForm("wicketBean", dogs, meta));

Regards
Fernando

Fer

unread,
Apr 23, 2009, 5:00:56 PM4/23/09
to Wicket Web Beans
I'm in the 1.0 version not in the 1.1 of WWB. Is this "bug" fixed in
the current version?

Dan Syrstad

unread,
Apr 23, 2009, 10:22:23 PM4/23/09
to wicket-w...@googlegroups.com
Yes, you should be using the 1.1 version. 1.0 is quite old.
-Dan

Fernando Boucquez

unread,
Apr 24, 2009, 9:24:22 AM4/24/09
to wicket-w...@googlegroups.com
Thanks you very much Dan for the quick anwser.

I just checkout from yours svn the WWB 1.1 project and installed in my repository.
I do this because i need to run WWB with wicket 1.42rc.

To make it works i fallow the migration strategy:

http://cwiki.apache.org/WICKET/migrate-14.html


Now, the WWB lib works with 1.4 but it doesn't use the benefit of generics.

Thanks you again Dan, i will continue my test of WWB. It's a very cool lib!

If you have no problem, could i send more mails with questions or issues?

Regards Fernando

Dan Syrstad

unread,
Apr 24, 2009, 11:09:28 AM4/24/09
to wicket-w...@googlegroups.com
Hi Fernando,

You can definitely send more questions and issues to the group. That's why it's here!
-Dan

Fernando Boucquez

unread,
Apr 24, 2009, 11:32:24 AM4/24/09
to wicket-w...@googlegroups.com
Thank you Dan!

I just compile and run the WWB 1.1 adapted to Wicket 1.4 and the issue of sorting primitive properties remains.

To fix that, i replaced the method isSortable() of the class inner class BeanElementColumn from:

public boolean isSortable(){
            return !element.isAction() && Comparable.class.isAssignableFrom(element.getPropertyType());
}

To:

  public boolean isSortable() {
           return !element.isAction() && (element.getPropertyType().isPrimitive() ||       Comparable.class.isAssignableFrom(element.getPropertyType()));
}

This solution works because the method PropertyResolver.getValue(propertyName, bean); return the non primitive value of the property. (and is comparable). This is why the PropertyComparator class works just fine.

Regards, Fernando

Dan Syrstad

unread,
Apr 26, 2009, 12:12:18 PM4/26/09
to wicket-w...@googlegroups.com
Hi Fernando,

I think this is a good catch! I will get this into the trunk and test it.

-Dan

Dan Syrstad

unread,
Apr 26, 2009, 1:16:37 PM4/26/09
to wicket-w...@googlegroups.com
Hi Fernando,

Thanks for the fix! I have integrated the change on the trunk and updated the table example to demonstrate it.

Best Regards,
-Dan

Fernando Boucquez

unread,
Apr 27, 2009, 1:44:19 PM4/27/09
to wicket-w...@googlegroups.com
Your welcome!  I've just seen the fix in the svn ;)
Regards
Fer
Reply all
Reply to author
Forward
0 new messages