Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete fails with stack trace when clearing and pressing enter after submit #20

Open
rjokelai opened this issue Mar 18, 2013 · 0 comments

Comments

@rjokelai
Copy link

The autocomplete component fails with stack trace when the input is cleared and submitted when a value has been selected previously. See attached code (Wicket 6.6.0, Wiquery 6.6.0). Could not attach a quickstart.

Steps to reproduce:

  1. Navigate to the page with the autocomplete
  2. Type 'One'. The autocomplete appears
  3. Select the entry
  4. Press 'submit'
  5. Clear the input and press enter -> stack trace
public class HomePage extends WebPage {
    private final List<TestObject> choices = Arrays.asList(new TestObject("One"), new TestObject("Two"), new TestObject("Three"));

    public HomePage() {
        Form<?> form = new Form<Void>("form");
        add(form);
        form.add(new AutocompleteComponent<TestObject>("autocomplete", new Model<TestObject>(), Model.ofList(choices), new ChoiceRenderer<TestObject>("value")) {
            @Override
            public TestObject getValueOnSearchFail(String input) {
                return new TestObject(input);
            }
        });
    }

    public static class TestObject implements Serializable {
        private String value;
        public TestObject(String value) {
            this.value = value;
        }
        public String getValue() {
            return value;
        }
    }
}
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">
    <body>
        <form wicket:id="form">
            <span wicket:id="autocomplete"></span>

            <button type="submit">
                Submit
            </button>
        </form>
    </body>
</html>

The stack trace

java.lang.NullPointerException
     at org.odlabs.wiquery.ui.autocomplete.AbstractAutocompleteComponent.convertInput(AbstractAutocompleteComponent.java:306)
     at org.apache.wicket.markup.html.form.FormComponent.validate(FormComponent.java:1137)
     at org.apache.wicket.markup.html.form.Form$16.validate(Form.java:1851)
     at org.apache.wicket.markup.html.form.Form$ValidationVisitor.component(Form.java:173)
     at org.apache.wicket.markup.html.form.Form$ValidationVisitor.component(Form.java:157)
     at org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:274)
     at org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:262)
     at org.apache.wicket.util.visit.Visits.visitPostOrder(Visits.java:245)
     at org.apache.wicket.markup.html.form.FormComponent.visitFormComponentsPostOrder(FormComponent.java:389)
     at org.apache.wicket.markup.html.form.Form.visitFormComponentsPostOrder(Form.java:1089)
     at org.apache.wicket.markup.html.form.Form.validateComponents(Form.java:1843)
     at org.apache.wicket.markup.html.form.Form.validate(Form.java:1808)
     at org.apache.wicket.markup.html.form.Form.process(Form.java:890)
     at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:767)
     at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:700)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
     at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
     at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
     at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
     at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:840)
     at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
     at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:254)
     at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:211)
     at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:282)
     at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:244)
     at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:188)
     at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:267)
     at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1332)
     at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:477)
     at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
     at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:524)
     at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
     at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1031)
     at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
     at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
     at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:965)
     at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
     at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
     at org.eclipse.jetty.server.Server.handle(Server.java:348)
     at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:452)
     at org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:47)
     at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:894)
     at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:948)
     at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:851)
     at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
     at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:66)
     at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:254)
     at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:603)
     at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:538)
     at java.lang.Thread.run(Thread.java:662)

Complete stack:

org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at [Form [Component id = form]] on component [Form [Component id = form]] threw an exception
     at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:268)
     at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
     at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
     at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
     at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:840)
     at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
     at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:254)
     at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:211)
     at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:282)
     at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:244)

java.lang.reflect.InvocationTargetException
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258)
     at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
     at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:240)
     at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:226)
     at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:840)
     at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
     at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:254)
     at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:211)
     at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:282)
     at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:244)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant