问题
Basically my java class that I want to sort should be working and we got the code for that. The thing is, when we try to simply just test if our link works(We got a link named "NAME" which should sort the list of people by the name, when clicked), by simply doing the code below. But it doesn't sort it. Our SQL is also correct so does anyone see the problem that we don't? We're fairly new to wicket.
public class SimpleView extends SimpleViewPage {
//denne er oprettet til brug til når der skal laves descending/ascending.
private final boolean descending = false;
ListView persons;
public SimpleView() {
persons = new ListView("persons", getPersons()) {
@Override
protected void populateItem(ListItem item) {
Person person = (Person) item.getModelObject();
item.add(new Label("name", person.getName()));
item.add(new Label("birthdate", person.getBirthdate()));
item.add(new Label("phone", person.getPhone()));
}
};
add(persons);
add(new Label("size", "Number of people: " + getPersons().size()));
add(new Link("namelink") {
@Override
public void onClick() {
persons = new ListView("persons", getPersons()) {
@Override
protected void populateItem(ListItem item) {
Person person = (Person) item.getModelObject();
item.add(new Label("name", person.getName()));
item.add(new Label("birthdate", person.getBirthdate()));
item.add(new Label("phone", person.getBirthdate()));
}
};
}
});
SQL IS THIS:
<resultMap type="com.netdesign.domain.Person" id="personResult">
<result property="name" column="name"/>
<result property="birthdate" column="birthdate"/>
<result property="phone" column="phone"/>
</resultMap>
<select id="sortBy" resultMap="personResult" >
SELECT * FROM person ORDER BY name DESC
</select>
Basically we just want our phone to update to birthdate, just so we can't see that our method works.
来源:https://stackoverflow.com/questions/25443397/wicket-mybatis-want-to-sort-a-row-but-cant-update-it