WelcomePage.java檢票:org.apache.wicket.markup.MarkupNotFoundException
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
import java.io.Serializable;
import java.util.ArrayList;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import com.ui.*;
public class WelcomePage extends WebPage{
private static final long serialVersionUID = 1L;
public WelcomePage(){
Contact contact = null;
final List<Contact> list = new ArrayList<Contact>();
char character;
// a - z
for(int i = 97; i < 123; i++){
character = (char) i;
contact = new Contact(String.valueOf(character));
list.add(contact);
}
final DataView<Contact> dataView =
new DataView<Contact>("simple", new ListDataProvider<Contact>(list)){
private static final long serialVersionUID = 1L;
@Override
public void populateItem(final Item<Contact> item){
final Contact user = item.getModelObject();
item.add(new Label("id", user.getId()));
}
};
dataView.setItemsPerPage(10);
add(dataView);
add(new PagingNavigator("navigator", dataView));
}
}
WelcomePage.html
<!DOCTYPE html>
<html>
<body>
<span wicket:id="lbl"> </span>
<wicket:extend>
<table cellspacing="0" class="dataview">
<tbody>
<tr wicket:id="simple">
<td><span wicket:id="id">Test ID</span></td>
</tr>
</tbody>
</table>
<div wicket:id="navigator"></div>
</wicket:extend>
</body>
</html>
上面的代碼是用於顯示數據視圖 - https://cwiki.apache.org/confluence/display/WICKET/A+Simple+DataView+Example
當我執行上面的代碼我收到以下錯誤..
Last cause: Can not determine Markup. Component is not yet connected to a parent. [Page class = com.kaiinos.kriti.ui.WelcomePage, id = 12, render count = 1]
堆棧跟蹤 - 根源:
org.apache.wicket.markup.MarkupNotFoundException: Can not determine Markup. Component is not yet connected to a parent. [Page class = com.kaiinos.kriti.ui.WelcomePage, id = 12, render count = 1]
at org.apache.wicket.Component.getMarkup(Component.java:751)
at org.apache.wicket.Component.internalRender(Component.java:2378)
at org.apache.wicket.Component.render(Component.java:2341)
at org.apache.wicket.Page.renderPage(Page.java:1018)
at org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:124)
at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:236)
at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:175)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:895)
at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293)
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
編輯 - 修改了Java代碼和HTML,但得到相同的error.I只是個初學者。 任何幫助,將不勝感激。Thankyou提前。
檢查您的標記,它是無效的:XML聲明必須是第一位的。 – svenmeier
...並且您正在使用,我們的BasePage是否有其標記? –
svenmeier
異常說「WelcomePage」,但你的Java代碼是關於Sub1Page的。另外你的HTML不完整。我需要結束元素,如