Hi, How is the "done" and "available" flag set in the Tld class by the TldChecker? Since you are using a separate Thread that sets these flags :
/* Iterate over the tlds and instantiate a TldChecker */ > for(Tld tld : tlds) > e.execute(new TldChecker(tld, query)); // Args could be for > instance "com", and "mydomain" > those variables needs to be set via for instance synchronized gets/and sets or declared volatile to garantuee visibility by other Threads. Another thing is, (I am not sure about this) is that if the Checkbox.isVisible method returns false wouldn't Wicket always complain since there is HTML markup but no corresponding Java component? Lars On Mon, Apr 21, 2008 at 4:30 PM, Edvin Syse <[EMAIL PROTECTED]> wrote: > Hi, > > I've created a "domain search" panel for Wicket. It consists of a ListView > that lists all the TLD's, and a checkbox so you can order if the domain is > available. To make it a bit fancy, I iterate over the list after > construction, and set a "TldChecker" to work on each tld. Basically, it > performs a whois search, and sets some boolean values on the tld after it's > finished. > > Then I have a AbstractAjaxTimerBehavior running every 500 milliseconds > that adds any tld that has finished the whois-search to the > AjaxRequestTarget. This works most of the times, but on some occations, > Wicket will complain about a mismatch in the hierachy. That's obviously not > the case, so I suspect the threading causes some kind of strange situation. > The pertinent code: > > /* The list */ > final List<Tld> tlds = Collections.synchronizedList(getTlds()); > > /* A basic executor to spin off the threads */ > Executor e = new Executor() { > public void execute(Runnable command) { > new Thread(command).start(); > } > }; > > /* Iterate over the tlds and instantiate a TldChecker */ > for(Tld tld : tlds) > e.execute(new TldChecker(tld, query)); // Args could be for > instance "com", and "mydomain" > > > /* The ListView - simplified */ > results = new ListView("results", tlds) { > protected void populateItem(ListItem item) { > final Tld tld = (Tld) item.getModelObject(); > item.setOutputMarkupId(true); > > /* Link to show who owns the domain if it's taken */ > item.add(new Link("taken") { > public boolean isVisible() { > return tld.getDone() && !tld.getAvailable() > && !tld.getIllegal(); > } > public void onClick() { > setResponsePage(new WhoisPage(query)); > } > }.setPopupSettings(new PopupSettings())); > > /* Checkbox so it can be ordered */ > item.add(new CheckBox("selected", new PropertyModel(tld, > "selected")) { > public boolean isVisible() { > return (tld.getDone() && > tld.getAvailable()); > } > }); > > /* Some other fields, showing spinner while !tld.getDone() > etc */ > } > } > > > /* The timer - it stops when all the TldChekers are finished. 'Published' > means it has been added to the request target */ > add(new AbstractAjaxTimerBehavior(Duration.milliseconds(500)) { > protected void onTimer(AjaxRequestTarget target) { > int running = 0; > synchronized (tlds) { > for(int i = 0; i < tlds.size(); i++) { > Tld tld = tlds.get(i); > if(!tld.getDone()) > running++; > if(tld.getDone() && !tld.getPublished()) { > Component theTr = > results.get(String.valueOf(i)); > target.addComponent(theTr); > target.appendJavascript("fadein('" > + theTr.getMarkupId() +"');"); // JQuery Magick, has nothing to do with the > problem, tried to remove it > tld.setPublished(true); > } > } > } > if(running == 0) > stop(); > } > }); > > /* The HTML for the ListView */ > <tr wicket:id="results"> > <td class="domain"><span > wicket:id="domain">Domain</span></td> > <td> > <input type="checkbox" wicket:id="selected"/> > <a class="taken" wicket:id="taken">taken</a> > <!-- Some more markup, removed for brevity, like this > one: > <span class="searching" > wicket:id="searching">searching</span> > --> > </td> > </tr> > > Wicket will complain about the checkbox with wicket:id "selected". If I > remove the isVisible() method, it never fails: > > public boolean isVisible() { > return (tld.getDone() && tld.getAvailable()); > } > > What might I be doing wrong? Any idea? :)) > > Here's Wicket's complaint at the time of the error: > > 13:13:39,186 ERROR [RequestCycle] [btpool0-1 - > /?wicket:interface=:5:searchInputPanel:searchInputForm::IFormSubmitListener::] > 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 = selected, page = > no.tornado.web.modules.domorder.DomainSearchPage, path = > 6:searchResultPanel:f:results:0:selected.DomainSearchResultPanel$3$2, > isVisible = true, isVersioned = false]] > > 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 = selected, page = > no.tornado.web.modules.domorder.DomainSearchPage, path = > 6:searchResultPanel:f:results:0:selected.DomainSearchResultPanel$3$2, > isVisible = true, isVersioned = false]] > > at org.apache.wicket.Page.checkRendering(Page.java:1116) > at org.apache.wicket.Page.renderPage(Page.java:914) > at > org.apache.wicket.protocol.http.WebRequestCycle.redirectTo(WebRequestCycle.java:163) > at > org.apache.wicket.request.target.component.PageRequestTarget.respond(PageRequestTarget.java:58) > at > org.apache.wicket.request.AbstractRequestCycleProcessor.respond(AbstractRequestCycleProcessor.java:104) > at > org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1172) > at org.apache.wicket.RequestCycle.step(RequestCycle.java:1243) > at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1330) > at org.apache.wicket.RequestCycle.request(RequestCycle.java:493) > at > org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:358) > at > org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:194) > at > org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1084) > at > org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360) > at > org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216) > at > org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181) > at > org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726) > at > org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405) > at > org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152) > at org.mortbay.jetty.Server.handle(Server.java:320) > at > org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505) > at > org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842) > at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648) > at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211) > at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380) > at > org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228) > at > org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450) > > Normally, I need to search for a few domain names before the error occurs. > > -- Edvin > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >