AjaxFormValidatingBehavior: getting NotSerializableExc
Hello guys, I'm having a little problem with the use of AjaxFormValidatingBehavior. I add it to all my fields, using a visitor. form.visitChildren(FormComponent.class, new IVisitor() { public Object component(Component component) { if (component instanceof TextField) { component.add(new AjaxFormValidatingBehavior(form, "onkeyup") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target) { super.onError(target); updateFieldsCssClasses(); } @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); updateFieldsCssClasses(); } }); } else if (component instanceof DropDownChoice || component instanceof CheckBox) { component.add(new AjaxFormValidatingBehavior(form, "onclick") { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target) { super.onError(target); updateFieldsCssClasses(); } @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); updateFieldsCssClasses(); } }); } return null; } }); But when this code is rendered, it throws this exception: org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: xxx$10 Field hierarchy is: 2 [class=xxx, path=2] ... at java.lang.Thread.run(Unknown Source) Caused by: java.io.NotSerializableException: xxx.$10 at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) However, AjaxFormValidatingBehavior implements Seriablizable... so I don't understand why Wicket complains about it... Have I miss something? PS: it works this way under at least 1.3.0 and 1.3.1 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AjaxFormValidatingBehavior: getting NotSerializableExc
My first guess is that the IVisitor is not serializable. Since you create two nested anonymous inner classes inside one another, the behaviors keep a reference to the IVisitor. Martijn On 2/6/08, Sébastien Piller [EMAIL PROTECTED] wrote: Hello guys, I'm having a little problem with the use of AjaxFormValidatingBehavior. I add it to all my fields, using a visitor. form.visitChildren(FormComponent.class, new IVisitor() { public Object component(Component component) { if (component instanceof TextField) { component.add(new AjaxFormValidatingBehavior(form, onkeyup) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target) { super.onError(target); updateFieldsCssClasses(); } @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); updateFieldsCssClasses(); } }); } else if (component instanceof DropDownChoice || component instanceof CheckBox) { component.add(new AjaxFormValidatingBehavior(form, onclick) { private static final long serialVersionUID = 1L; @Override protected void onError(AjaxRequestTarget target) { super.onError(target); updateFieldsCssClasses(); } @Override protected void onSubmit(AjaxRequestTarget target) { super.onSubmit(target); updateFieldsCssClasses(); } }); } return null; } }); But when this code is rendered, it throws this exception: org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: xxx$10 Field hierarchy is: 2 [class=xxx, path=2] ... at java.lang.Thread.run(Unknown Source) Caused by: java.io.NotSerializableException: xxx.$10 at java.io.ObjectOutputStream.writeObject0(Unknown Source) at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source) However, AjaxFormValidatingBehavior implements Seriablizable... so I don't understand why Wicket complains about it... Have I miss something? PS: it works this way under at least 1.3.0 and 1.3.1 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Buy Wicket in Action: http://manning.com/dashorst Apache Wicket 1.3.0 is released Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.0 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: AjaxFormValidatingBehavior: getting NotSerializableExc
That's it! I'm too stupid... sorry for the disturbing ;) Martijn Dashorst a écrit : My first guess is that the IVisitor is not serializable. Since you create two nested anonymous inner classes inside one another, the behaviors keep a reference to the IVisitor. Martijn - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]