You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martijn Dashorst <ma...@gmail.com> on 2008/02/06 12:09:25 UTC

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 <pi...@hmcrecord.ch> 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: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org


-- 
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: AjaxFormValidatingBehavior: getting NotSerializableExc

Posted by Sébastien Piller <pi...@hmcrecord.ch>.
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: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org