ここで間違っているImを見つけられません。私はそれについていくつかのチュートリアルを読んで、それをどうやってやるべきかの "彼らの"バージョンを試しました。 Netbeansはエラーを起こすことはありませんが、ブラウザにはエラーがあります。 彼女は私のコードです。任意のヒントDefaultDataTableコンポーネントがスタックされています - エラーが見つかりません
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("[email protected]");
u.setStartDato(new Date());
u.setPassord("passord");
brukere.add(u);
u1.setForNavn("Hanne");
u1.setEtterNavn("Ås");
u1.setTelefonnummer("99324766");
u1.setMailadresse("[email protected]");
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
希望、これは十分な情報..です
おかげで、ファイルRegistrerteBrukere.javaで
:それはで
を交換することによって修正されました。私は昨日インターネット上でこの説明を見つけました。私はエラーメッセージを尋ねました。私はちょうどドットを接続することができませんでした... :-) –