On Fri, 2011-12-30 at 12:46 +0100, Rahman USTA wrote:
> Hi, i wanna add an item to DropDownChoice's List after form submitted. i
> used for example,
> 
> 
> 
> private List<String> *cities*=Arrays.asList("İstanbul","Ankara","Kayseri");

The Exception is thrown because Arrays.asList returns a List
implementation that does not offer an add() implementation. (This is
allowed by the List API.) (This is not a Wicket issue.)

Change the above line to:

pivate List<String> cities = new ArrayList<String>();
java.util.Collections.addAll(cities, "İstanbul","Ankara","Kayseri");

Cheers,
Chantal


> 
>    final DropDownChoice<String> cityList=new
> DropDownChoice<String>("sehirListesi", Model.of("İstanbul"),
>                 new PropertyModel<List<? extends String>>(this,"cities"));
> 
> then
> 
> Form form=new Form("form"){
>             @Override
>             public void onSubmit() {
> 
>                 *cities*.add("İzmir");
>                 info("Form başarıyla gönderildi");
> 
>             }
>         };
> 
> but, i get this exceptions.
> 
> --------------------
> Unexpected RuntimeException
> 
> Last cause: null
> WicketMessage: Method onFormSubmitted of interface
> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at [
> [Component id = form]] on component [ [Component id = form]] threw an
> exception
> 
>  Stacktrace
> 
> Root cause:
> 
> java.lang.UnsupportedOperationException
>      at java.util.AbstractList.add(AbstractList.java:131)
>      at java.util.AbstractList.add(AbstractList.java:91)
>      at com.usta.HomePage$1.onSubmit(HomePage.java:74)
>      at org.apache.wicket.markup.html.form.Form$10.component(Form.java:1189)
>      at org.apache.wicket.markup.html.form.Form$10.component(Form.java:1184)
>      at 
> org.apache.wicket.util.visit.Visits.visitPostOrderHelper(Visits.java:273)
>      at org.apache.wicket.util.visit.Visits.visitPostOrder(Visits.java:244)
>      at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1182)
>      at org.apache.wicket.markup.html.form.Form.process(Form.java:838)
>      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:762)
>      at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:692)
>      at java.lang.reflect.Method.invoke(Method.java:597)
>      at 
> org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:260)
>      at 
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
>      at 
> org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:248)
>      at 
> org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234)
>      at 
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:750)
>      at 
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:252)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:209)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:280)
>      at 
> org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:162)
>      at 
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:218)
>      at 
> org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1326)
>      at 
> org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:479)
>      at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
>      at 
> org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
>      at 
> org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
>      at 
> org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:940)
>      at 
> org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
>      at 
> org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
>      at 
> org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874)
>      at 
> org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
>      at 
> org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
>      at org.eclipse.jetty.server.Server.handle(Server.java:349)
>      at 
> org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
>      at 
> org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:921)
>      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:784)
>      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:223)
>      at 
> org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:50)
>      at 
> org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:245)
>      at 
> org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
>      at 
> org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
>      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 [ [Component id = form]] on component [ [Component id =
> form]] threw an exception
>      at 
> org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:270)
>      at 
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
>      at 
> org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:248)
>      at 
> org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234)
>      at 
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:750)
>      at 
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:252)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:209)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:280)
>      at 
> org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:162)
> 
> 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:260)
>      at 
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:216)
>      at 
> org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:248)
>      at 
> org.apache.wicket.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:234)
>      at 
> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:750)
>      at 
> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:252)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:209)
>      at 
> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:280)
>      at 
> org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:162)
> 
>  display page 
> view<http://localhost:8080/wicket/page?2-1.ILinkListener-displayPageViewLink>
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to