Bonjour à tous,
J'ai découvert Wicket il y a peu (quelques jours) et j'essaie de m'y former via le livre "Wicket In Action". Pour ceux qui possède le livre, je suis à la page 65.
Ma question (même si vous n'avez pas le livre, vous pouvez m'aider):
J'ai une liste de differents éléments à afficher et il conseille de passer par un "navigator" (càd montrer PAGE1, PAGE2,....).
J'ai suivi le tuto, mais cela ne fonctionne pas.
HTML:
JAVA:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11 <div id="main"> <div class="cheese" wicket:id="cheeses"> <h3 wicket:id="name">Gouda</h3> <p wicket:id="description">Gouda is a Dutch...</p> <p> <span wicket:id="price">$1.99</span> <a wicket:id="add" href="#">add to cart</a> </p> </div> <div wicket:id="navigator"></div> </div>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 PageableListView<Cheese> cheeses = new PageableListView<Cheese>("cheeses", getCheeses(), 5){ @Override protected void populateItem(ListItem<Cheese> item) { Cheese cheese = (Cheese) item.getModelObject(); item.add(new Label("name",cheese.getName())); item.add(new Label("description", cheese.getDescription())); item.add(new Label("price", "$"+cheese.getPrice())); item.add(new Link("add", item.getModel()) { @Override public void onClick() { Cheese selectedCheese = (Cheese) getModelObject(); getCart().getCheeses().add(selectedCheese); } }); } }; add(cheeses); add(new PagingNavigation("navigator", cheeses));
Lorsque je lance, je reçois le message suivant:
WicketMessage: The component(s) below failed to render. A common problem is that you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered).1. [MarkupContainer [Component id = pageLink]]2. [Component id = pageNumber]3. [MarkupContainer [Component id = pageLink]]4. [Component id = pageNumber]5. [MarkupContainer [Component id = pageLink]]6. [Component id = pageNumber]Root cause:org.apache.wicket.WicketRuntimeException: The component(s) below failed to render. A common problem is that you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered).1. [MarkupContainer [Component id = pageLink]]2. [Component id = pageNumber]3. [MarkupContainer [Component id = pageLink]]4. [Component id = pageNumber]5. [MarkupContainer [Component id = pageLink]]6. [Component id = pageNumber] at org.apache.wicket.Page.checkRendering(Page.java:1200) at org.apache.wicket.Page.renderPage(Page.java:940) at org.apache.wicket.request.target.component.BookmarkablePageRequestTarget.respond(BookmarkablePageRequestTarget.java:261) at org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:105) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1258) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1436) 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:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:182) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
Partager