ここで何が間違っているのかわかりません。私はそれについていくつかのチュートリアルを読み、それがどのように行われるべきかの「彼らの」バージョンを試しました。Netbeans ではエラーが発生しませんが、ブラウザではエラーが発生します。彼女は私のコードです。どんなヒントでも大歓迎です
RegistrerteBrukere.java
package com.myapp.wicket;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DefaultDataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.model.Model;
/**
*
* @author Bjørn J Aurheim
*/
public final class RegistrerteBrukere extends BasePage {
private DefaultDataTable<Bruker> table;
private int antallRekkerPrSide = 50;
private BrukerProvider provider = new BrukerProvider();
public RegistrerteBrukere() {
super();
// opprette testdata i liste for datatabellen
// List<IColumn<Bruker>> kolonner = new ArrayList<IColumn<Bruker>>();
List kolonner = new ArrayList();
kolonner.add(new PropertyColumn<Bruker>(new Model("Fornavn"),"bruker","bruker"));
kolonner.add(new PropertyColumn<Bruker>(new Model("Etternavn"),"etternavn","bruker"));
kolonner.add(new PropertyColumn<Bruker>(new Model("Telefonnummer"),"telefonnummer","telefonnummer"));
kolonner.add(new PropertyColumn<Bruker>(new Model("Mailadresse"),"mailadresse","mailadresse"));
kolonner.add(new PropertyColumn<Bruker>(new Model("StartDato"),"startdato","startdato"));
kolonner.add(new PropertyColumn<Bruker>(new Model("Passord"),"passord","passord"));
table = new DefaultDataTable<Bruker>("brukertable", kolonner, provider, antallRekkerPrSide);
add(table);
}
public RegistrerteBrukere(PageParameters params) {
//TODO: process page parameters
}
}
RegistrerteBrukere.html
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:wicket="http://wicket.apache.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>RegistrerteBrukere</title>
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<wicket:extend>
<table wicket:id="brukertable" class="brukere"></table>
</wicket:extend>
</body>
</html>
BrukerProvider.java
public class BrukerProvider extends SortableDataProvider<Bruker>{
Bruker u = new Bruker();
Bruker u1 = new Bruker();
private static List<Bruker> brukere = Arrays.asList( );
public BrukerProvider(){
setSort("fornavn",true);
u.setForNavn("Tore");
u.setEtterNavn("Hansen");
u.setTelefonnummer("99887766");
u.setMailadresse("noen@home.her");
u.setStartDato(new Date());
u.setPassord("passord");
brukere.add(u);
u1.setForNavn("Hanne");
u1.setEtterNavn("Ås");
u1.setTelefonnummer("99324766");
u1.setMailadresse("noener@homdfe.her");
u1.setStartDato(new Date());
u1.setPassord("passsdford");
brukere.add(u1);
}
@Override
public Iterator<? extends Bruker> iterator(int first, int count){
List<Bruker> data = new ArrayList<Bruker>(brukere);
Collections.sort (data, new Comparator<Bruker>(){
@Override
public int compare(Bruker o1, Bruker o2) {
int dir = getSort().isAscending() ? 1: -1;
if ("fornavn".equals(getSort().getProperty())){
return dir * (o1.getForNavn().compareTo(o2.getForNavn()));
} else {
return dir * (o1.getEtterNavn().compareTo(o2.getEtterNavn()));
}
}
});
return data.subList(first, Math.min(first + count, data.size())).iterator();
}
@Override
public int size(){
return brukere.size();
}
@Override
public IModel<Bruker> model(Bruker object){
return Model.of(object);
}
}
私のエラーメッセージ:
WicketMessage: Can't instantiate page using constructor public com.myapp.wicket.RegistrerteBrukere()
Root cause:
java.lang.UnsupportedOperationException
at java.util.AbstractList.add(AbstractList.java:148)
at java.util.AbstractList.add(AbstractList.java:108)
at com.myapp.wicket.BrukerProvider.<init>(BrukerProvider.java:29)
at com.myapp.wicket.RegistrerteBrukere.<init>(RegistrerteBrukere.java:24)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:192)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1279)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1358)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1465)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:319)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:405)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Complete stack:
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor public com.myapp.wicket.RegistrerteBrukere()
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:212)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1279)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1358)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1465)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.apache.wicket.session.DefaultPageFactory.createPage(DefaultPageFactory.java:192)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:57)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.newPage(BookmarkablePageRequestTarget.java:298)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.getPage(BookmarkablePageRequestTarget.java:320)
at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.processEvents(BookmarkablePageRequestTarget.java:234)
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1279)
at org.apache.wicket.RequestCycle.step(RequestCycle.java:1358)
at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1465)
at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:486)
display page view
これが十分な情報であることを願っています..