RE: serialization question
Is there a hook point to serialization of components? We would like to throw a WicketRuntimeException if we detect that we are about to attempt to serialize out an attached (in our case Hibernate) entity rather than using a LoadableDetachableModel and only serializing the id. I usually solve that problem by having a LDM-like model that has a transient (thus not serialized) reference to the actual object, and a load()-method using the id to get the actual object if null. But: Since you are in control over what types of models are used in the code, how do you end up with models that reference Hibernate objects in a way that will try and serialize them? - Tor Iver - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
serialization question
Is there a hook point to serialization of components? We would like to throw a WicketRuntimeException if we detect that we are about to attempt to serialize out an attached (in our case Hibernate) entity rather than using a LoadableDetachableModel and only serializing the id. I see I can register an DetachListener, but that doesn't fire until after the model is detached and that doesn't help in these cases I think. We have had issues where we actually OOM the server when trying to serialize an entity that has LOTS of associations. I'd like to throw the exception before the serialization is even attempted. We are using wicket 1.4.17.
Re: serialization question
In Wicket 1.4 see org.apache.wicket.util.io.IObjectStreamFactory. In Wicket 1.5 org.apache.wicket.serialize.ISerializer On Mon, Aug 15, 2011 at 5:50 PM, Steve Lowery slow...@gatessolutions.com wrote: Is there a hook point to serialization of components? We would like to throw a WicketRuntimeException if we detect that we are about to attempt to serialize out an attached (in our case Hibernate) entity rather than using a LoadableDetachableModel and only serializing the id. I see I can register an DetachListener, but that doesn't fire until after the model is detached and that doesn't help in these cases I think. We have had issues where we actually OOM the server when trying to serialize an entity that has LOTS of associations. I'd like to throw the exception before the serialization is even attempted. We are using wicket 1.4.17. -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
Then just keep the criteria to get those items in your components? samb0057 wrote: The value objects are not simple attributes of an entity. Let me explain what they do (a little simplified but the fundamentals are there). We have a research module that performs pricing research. ResearchItem CellPhoneResearchItem IPodResearchItem LaptopResearchItem Etc Since the identity of these research items is defined solely by their attributes they are implemented as value objects. I know this is different from your everyday value object (eg Address) Does this sound like maybe a problem that should be addressed in the domain model? Value objects were chosen since it makes it much easier in many other areas to just create a new research item, rather than call repositories to load old ones (impossible in some places). No point in loading something you know all the attributes of. The only way to get them reliably is to call ResearchItemGenerationService.generateResearchItems() -- View this message in context: http://old.nabble.com/another-serialization-question-tp26295325p26297467.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
How do you already know the attributes of all of the research items? Does that mean that you could enumerate them? On Nov 11, 2009 12:23 AM, Sam Barrow s...@sambarrow.com wrote: The value objects are not simple attributes of an entity. Let me explain what they do (a little simplified but the fundamentals are there). We have a research module that performs pricing research. ResearchItem CellPhoneResearchItem IPodResearchItem LaptopResearchItem Etc Since the identity of these research items is defined solely by their attributes they are implemented as value objects. I know this is different from your everyday value object (eg Address) Does this sound like maybe a problem that should be addressed in the domain model? Value objects were chosen since it makes it much easier in many other areas to just create a new research item, rather than call repositories to load old ones (impossible in some places). No point in loading something you know all the attributes of. The only way to get them reliably is to call ResearchItemGenerationService.generateResearchItems() -Original Message- From: James Carman jcar...@carmanconsulting.com Date: Wed, 11 Nov 2009... Subject: Re: another serialization question Can you go through the entity to get to these objects? ...
another serialization question
One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
Are you designing these value objects from scratch? Do you have control over them? Then, why are you averse to making them serializable? If you have a valid reason to not make them serializable, then why not go with the DTO pattern and just figure out a way to copy the attributes back and forth between your value objects and your DTOs? On Tue, Nov 10, 2009 at 10:17 PM, Sam Barrow s...@sambarrow.com wrote: But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
I cannot make them serializable I don't have control over them. But even if I did I couldn't because the valueobject has a reference to an entity which cannot be serializable. The project also uses db4o which would make it much harder to use a serialized version. Is dtos the best/only way? It would be a very awkward design because I have to both deal with subclasses of valueobject and converting the objects back when calling the service layer --Original Message-- From: James Carman To: users@wicket.apache.org ReplyTo: users@wicket.apache.org Subject: Re: another serialization question Sent: Nov 10, 2009 11:39 PM Are you designing these value objects from scratch? Do you have control over them? Then, why are you averse to making them serializable? If you have a valid reason to not make them serializable, then why not go with the DTO pattern and just figure out a way to copy the attributes back and forth between your value objects and your DTOs? On Tue, Nov 10, 2009 at 10:17 PM, Sam Barrow s...@sambarrow.com wrote: But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
Can you go through the entity to get to these objects? Meaning, can you set up and LDM to get the root entity object and then traverse to get to the value object you're interested in? If so, then you can try to come up with some property path to get you there and use that to refer to the specific value object you're wanting to edit/view. On Tue, Nov 10, 2009 at 11:46 PM, Sam Barrow s...@sambarrow.com wrote: I cannot make them serializable I don't have control over them. But even if I did I couldn't because the valueobject has a reference to an entity which cannot be serializable. The project also uses db4o which would make it much harder to use a serialized version. Is dtos the best/only way? It would be a very awkward design because I have to both deal with subclasses of valueobject and converting the objects back when calling the service layer --Original Message-- From: James Carman To: users@wicket.apache.org ReplyTo: users@wicket.apache.org Subject: Re: another serialization question Sent: Nov 10, 2009 11:39 PM Are you designing these value objects from scratch? Do you have control over them? Then, why are you averse to making them serializable? If you have a valid reason to not make them serializable, then why not go with the DTO pattern and just figure out a way to copy the attributes back and forth between your value objects and your DTOs? On Tue, Nov 10, 2009 at 10:17 PM, Sam Barrow s...@sambarrow.com wrote: But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: another serialization question
The value objects are not simple attributes of an entity. Let me explain what they do (a little simplified but the fundamentals are there). We have a research module that performs pricing research. ResearchItem CellPhoneResearchItem IPodResearchItem LaptopResearchItem Etc Since the identity of these research items is defined solely by their attributes they are implemented as value objects. I know this is different from your everyday value object (eg Address) Does this sound like maybe a problem that should be addressed in the domain model? Value objects were chosen since it makes it much easier in many other areas to just create a new research item, rather than call repositories to load old ones (impossible in some places). No point in loading something you know all the attributes of. The only way to get them reliably is to call ResearchItemGenerationService.generateResearchItems() -Original Message- From: James Carman jcar...@carmanconsulting.com Date: Wed, 11 Nov 2009 00:10:15 To: users@wicket.apache.org Subject: Re: another serialization question Can you go through the entity to get to these objects? Meaning, can you set up and LDM to get the root entity object and then traverse to get to the value object you're interested in? If so, then you can try to come up with some property path to get you there and use that to refer to the specific value object you're wanting to edit/view. On Tue, Nov 10, 2009 at 11:46 PM, Sam Barrow s...@sambarrow.com wrote: I cannot make them serializable I don't have control over them. But even if I did I couldn't because the valueobject has a reference to an entity which cannot be serializable. The project also uses db4o which would make it much harder to use a serialized version. Is dtos the best/only way? It would be a very awkward design because I have to both deal with subclasses of valueobject and converting the objects back when calling the service layer --Original Message-- From: James Carman To: users@wicket.apache.org ReplyTo: users@wicket.apache.org Subject: Re: another serialization question Sent: Nov 10, 2009 11:39 PM Are you designing these value objects from scratch? Do you have control over them? Then, why are you averse to making them serializable? If you have a valid reason to not make them serializable, then why not go with the DTO pattern and just figure out a way to copy the attributes back and forth between your value objects and your DTOs? On Tue, Nov 10, 2009 at 10:17 PM, Sam Barrow s...@sambarrow.com wrote: But some the ValueObject classes contain a reference to an entity. Keep in mind I mean ValueObject in the context of domain driven design, not a DTO / data transfer object. On Tue, 2009-11-10 at 22:12 -0500, James Carman wrote: ValueObjects (if you're following the design pattern) should be serializable. On Tue, Nov 10, 2009 at 10:03 PM, Sam Barrow s...@sambarrow.com wrote: One more question about serializing objects. I have a page in the application that I'm working on that calls an application service which returns a collection of objects of a type I'll call ValueObject (not serializable). ValueObject has many subclasses (which are of no concern to my wicket ui, which only deals with the ValueObject interface). So i have a page which calls the service and now has a collection of ValueObjects. What is the best way to pass this object to another page? Keep in mind it is not serializable and has no identity i can look it up by - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Serialization question
Hi, I don't see any problem with the code below, that is, from what you pasted I don't see any references to a TextFieldDecorator being kept. However when Wicket says that something is not serializable it gives you the entire object graph path to the object that is causing the problem, so seeing the full exception would help debug the problem. Regards, Sebastiaan Martijn Lindhout wrote: Hi all, I have this code in a Panel: TextField name = new TextField(name, new PropertyModel(person, name.value )); add(WidgetDecorator.decorate(name).from(person.getName()); I have domain objects (person) with rich type definities. getName() returns a Text object that contains all constraints imposed on the field (required, min, max, etc). WidgetDecorator is a class I build that enriches a particular Wicket component, based on the type information from the domain object. All decorate methods on the WidgetDecorator are static and return a component specific decorator, so in the sample above a new TextFieldDecorator will be instantiated and returned. It looks like this: public class TextFieldDecorator { private TextField widget; public TextFieldDecorator(TextField textField) { this.widget = textField; } public TextField from(Text textType) { widget.setRequired(textType.isRequired()); widget.add(StringValidator.lengthBetween(textType.getMinLength(), textType.getMaxLength())); widget.setLabel(new Model(textType.getFieldName())); return widget; } } Now the problem: Wicket complains that my TextFieldDecorator is not serializable. But why? IMO it is not added to the component hierarchy. The argument to the panel.add(...) method is the result of evaluating: WidgetDecorator.decorate(name).from(person.getName(), which returns the TextField widget. Should I redo my Java programmers exam? Thanx, smime.p7s Description: S/MIME Cryptographic Signature
Re: Serialization question
Here it is: ERROR - Objects- Error serializing object class nl.je.obs.web.admin.medewerkers.EditMedewerker [object=[Page class = nl.je.obs.web.admin.medewerkers.EditMedewerker, id = 3, version = 0]] org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException:Unable to serialize class: nl.je.ddd.ui.wicket.DateTextFieldDecorator Field hierarchy is: 3 [class=nl.je.obs.web.admin.medewerkers.EditMedewerker, path=3] private java.lang.Object org.apache.wicket.MarkupContainer.children[class=[ Ljava.lang.Object;] private org.apache.wicket.markup.html.ContainerWithAssociatedMarkupHelper org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.markupHelper[2] [class=nl.je.obs.web.admin.medewerkers.EditMedewerker$2, path=3:mwpwForm] private java.lang.Object org.apache.wicket.MarkupContainer.children[class=[ Ljava.lang.Object;] private java.lang.Object org.apache.wicket.MarkupContainer.children[0] [class= org.apache.wicket.extensions.markup.html.tabs.TabbedPanel, path=3:mwpwForm:mw-tabs] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private org.apache.wicket.markup.html.link.PopupSettings org.apache.wicket.markup.html.link.Link.popupSettings[1] [class= nl.je.obs.web.admin.medewerkers.PersoonsGegevensPanel, path=3:mwpwForm:mw-tabs:panel] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private java.lang.Object org.apache.wicket.markup.html.form.FormComponent.validators[3] [class= org.apache.wicket.datetime.markup.html.form.DateTextField, path=3:mwpwForm:mw-tabs:panel:geboorted] java.lang.Object org.apache.wicket.Component.data[class=[ Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[0][1] [class=nl.je.ddd.ui.wicket.DateTextFieldDecorator$1] final nl.je.ddd.ui.wicket.DateTextFieldDecorator nl.je.ddd.ui.wicket.DateTextFieldDecorator$1.this$0 [class= nl.je.ddd.ui.wicket.DateTextFieldDecorator] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:342) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.writeObjectOverride( SerializableChecker.java:678) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:322) at org.apache.wicket.util.io.IObjectStreamFactory$2.writeObjectOverride( IObjectStreamFactory.java:125) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:322) at org.apache.wicket.util.lang.Objects.objectToByteArray(Objects.java :1085) at org.apache.wicket.protocol.http.pagestore.AbstractPageStore.serializePage( AbstractPageStore.java:197) at org.apache.wicket.protocol.http.pagestore.DiskPageStore.storePage( DiskPageStore.java:806) at org.apache.wicket.protocol.http.SecondLevelCacheSessionStore$SecondLevelCachePageMap.put (SecondLevelCacheSessionStore.java:332) at org.apache.wicket.Session.requestDetached(Session.java:1364) at org.apache.wicket.RequestCycle.detach(RequestCycle.java:1091) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1334) at org.apache.wicket.RequestCycle.request(RequestCycle.java:493) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java :354) at
Re: Serialization question
SOrry, it is the DateTextFieldDecorator that's causing the problem, and its code is: public class DateTextFieldDecorator { private DateTextField widget; public DateTextFieldDecorator(DateTextField widget) { this.widget = widget; } public DateTextField from(DateType dateType) { widget.setRequired(dateType.isRequired()); widget.add(new DatePicker() { protected boolean enableMonthYearSelection() { return true; } }); widget.setLabel(new Model(dateType.getFieldName())); return widget; } } 2008/2/8, Martijn Lindhout [EMAIL PROTECTED]: Here it is: ERROR - Objects- Error serializing object class nl.je.obs.web.admin.medewerkers.EditMedewerker [object=[Page class = nl.je.obs.web.admin.medewerkers.EditMedewerker, id = 3, version = 0]] org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException:Unable to serialize class: nl.je.ddd.ui.wicket.DateTextFieldDecorator Field hierarchy is: 3 [class=nl.je.obs.web.admin.medewerkers.EditMedewerker, path=3] private java.lang.Object org.apache.wicket.MarkupContainer.children[class=[ Ljava.lang.Object;] private org.apache.wicket.markup.html.ContainerWithAssociatedMarkupHelper org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.markupHelper[2] [class=nl.je.obs.web.admin.medewerkers.EditMedewerker$2, path=3:mwpwForm] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private java.lang.Object org.apache.wicket.MarkupContainer.children[0] [class= org.apache.wicket.extensions.markup.html.tabs.TabbedPanel, path=3:mwpwForm:mw-tabs] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private org.apache.wicket.markup.html.link.PopupSettings org.apache.wicket.markup.html.link.Link.popupSettings[1] [class= nl.je.obs.web.admin.medewerkers.PersoonsGegevensPanel, path=3:mwpwForm:mw-tabs:panel] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private java.lang.Object org.apache.wicket.markup.html.form.FormComponent.validators[3] [class= org.apache.wicket.datetime.markup.html.form.DateTextField, path=3:mwpwForm:mw-tabs:panel:geboorted] java.lang.Object org.apache.wicket.Component.data[class=[ Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[0][1] [class=nl.je.ddd.ui.wicket.DateTextFieldDecorator$1] final nl.je.ddd.ui.wicket.DateTextFieldDecorator nl.je.ddd.ui.wicket.DateTextFieldDecorator$1.this$0 [class= nl.je.ddd.ui.wicket.DateTextFieldDecorator] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:342) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.writeObjectOverride( SerializableChecker.java:678) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:322) at org.apache.wicket.util.io.IObjectStreamFactory$2.writeObjectOverride( IObjectStreamFactory.java:125) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:322) at org.apache.wicket.util.lang.Objects.objectToByteArray(Objects.java
Re: Serialization question
I solved it, it is the anonymous subclass of DatePicker. Because it is defined in the decorator class, it belongs to it. I created a separate DatePickerExt class that enables month/year selection. 2008/2/8, Martijn Lindhout [EMAIL PROTECTED]: SOrry, it is the DateTextFieldDecorator that's causing the problem, and its code is: public class DateTextFieldDecorator { private DateTextField widget; public DateTextFieldDecorator(DateTextField widget) { this.widget = widget; } public DateTextField from(DateType dateType) { widget.setRequired(dateType.isRequired()); widget.add(new DatePicker() { protected boolean enableMonthYearSelection() { return true; } }); widget.setLabel(new Model(dateType.getFieldName())); return widget; } } 2008/2/8, Martijn Lindhout [EMAIL PROTECTED]: Here it is: ERROR - Objects- Error serializing object class nl.je.obs.web.admin.medewerkers.EditMedewerker [object=[Page class = nl.je.obs.web.admin.medewerkers.EditMedewerker, id = 3, version = 0]] org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException:Unable to serialize class: nl.je.ddd.ui.wicket.DateTextFieldDecorator Field hierarchy is: 3 [class=nl.je.obs.web.admin.medewerkers.EditMedewerker, path=3] private java.lang.Object org.apache.wicket.MarkupContainer.children[class=[ Ljava.lang.Object;] private org.apache.wicket.markup.html.ContainerWithAssociatedMarkupHelper org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.markupHelper[2] [class=nl.je.obs.web.admin.medewerkers.EditMedewerker$2, path=3:mwpwForm] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private java.lang.Object org.apache.wicket.MarkupContainer.children[0] [class= org.apache.wicket.extensions.markup.html.tabs.TabbedPanel, path=3:mwpwForm:mw-tabs] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private org.apache.wicket.markup.html.link.PopupSettings org.apache.wicket.markup.html.link.Link.popupSettings[1] [class= nl.je.obs.web.admin.medewerkers.PersoonsGegevensPanel, path=3:mwpwForm:mw-tabs:panel] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private java.lang.Object org.apache.wicket.markup.html.form.FormComponent.validators[3] [class= org.apache.wicket.datetime.markup.html.form.DateTextField, path=3:mwpwForm:mw-tabs:panel:geboorted] java.lang.Object org.apache.wicket.Component.data[class=[ Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[0][1] [class=nl.je.ddd.ui.wicket.DateTextFieldDecorator$1] final nl.je.ddd.ui.wicket.DateTextFieldDecorator nl.je.ddd.ui.wicket.DateTextFieldDecorator$1.this$0 [class= nl.je.ddd.ui.wicket.DateTextFieldDecorator] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:342) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.writeObjectOverride
Re: Serialization question
Hi, I'm glad you found it... Since inner classes are used so frequently in Wicket they're also frequently the ones that cause these problems. Unfortunately it is impossible to define static anonymous inner classes which means that instances of inner classes always keep a (hidden) reference to the instance of the outer class. Regards, Sebastiaan Martijn Lindhout wrote: I solved it, it is the anonymous subclass of DatePicker. Because it is defined in the decorator class, it belongs to it. I created a separate DatePickerExt class that enables month/year selection. 2008/2/8, Martijn Lindhout [EMAIL PROTECTED]: SOrry, it is the DateTextFieldDecorator that's causing the problem, and its code is: public class DateTextFieldDecorator { private DateTextField widget; public DateTextFieldDecorator(DateTextField widget) { this.widget = widget; } public DateTextField from(DateType dateType) { widget.setRequired(dateType.isRequired()); widget.add(new DatePicker() { protected boolean enableMonthYearSelection() { return true; } }); widget.setLabel(new Model(dateType.getFieldName())); return widget; } } 2008/2/8, Martijn Lindhout [EMAIL PROTECTED]: Here it is: ERROR - Objects- Error serializing object class nl.je.obs.web.admin.medewerkers.EditMedewerker [object=[Page class = nl.je.obs.web.admin.medewerkers.EditMedewerker, id = 3, version = 0]] org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException:Unable to serialize class: nl.je.ddd.ui.wicket.DateTextFieldDecorator Field hierarchy is: 3 [class=nl.je.obs.web.admin.medewerkers.EditMedewerker, path=3] private java.lang.Object org.apache.wicket.MarkupContainer.children[class=[ Ljava.lang.Object;] private org.apache.wicket.markup.html.ContainerWithAssociatedMarkupHelper org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup.markupHelper[2] [class=nl.je.obs.web.admin.medewerkers.EditMedewerker$2, path=3:mwpwForm] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private java.lang.Object org.apache.wicket.MarkupContainer.children[0] [class= org.apache.wicket.extensions.markup.html.tabs.TabbedPanel, path=3:mwpwForm:mw-tabs] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private org.apache.wicket.markup.html.link.PopupSettings org.apache.wicket.markup.html.link.Link.popupSettings[1] [class= nl.je.obs.web.admin.medewerkers.PersoonsGegevensPanel, path=3:mwpwForm:mw-tabs:panel] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] private java.lang.Object org.apache.wicket.markup.html.form.FormComponent.validators[3] [class= org.apache.wicket.datetime.markup.html.form.DateTextField, path=3:mwpwForm:mw-tabs:panel:geboorted] java.lang.Object org.apache.wicket.Component.data[class=[ Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[0][1] [class=nl.je.ddd.ui.wicket.DateTextFieldDecorator$1] final nl.je.ddd.ui.wicket.DateTextFieldDecorator nl.je.ddd.ui.wicket.DateTextFieldDecorator$1.this$0 [class= nl.je.ddd.ui.wicket.DateTextFieldDecorator] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:342) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields( SerializableChecker.java:610) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:533) at org.apache.wicket.util.io.SerializableChecker.check( SerializableChecker.java:388) at org.apache.wicket.util.io.SerializableChecker.checkFields(
Serialization question
Hi all, I have this code in a Panel: TextField name = new TextField(name, new PropertyModel(person, name.value )); add(WidgetDecorator.decorate(name).from(person.getName()); I have domain objects (person) with rich type definities. getName() returns a Text object that contains all constraints imposed on the field (required, min, max, etc). WidgetDecorator is a class I build that enriches a particular Wicket component, based on the type information from the domain object. All decorate methods on the WidgetDecorator are static and return a component specific decorator, so in the sample above a new TextFieldDecorator will be instantiated and returned. It looks like this: public class TextFieldDecorator { private TextField widget; public TextFieldDecorator(TextField textField) { this.widget = textField; } public TextField from(Text textType) { widget.setRequired(textType.isRequired()); widget.add(StringValidator.lengthBetween(textType.getMinLength(), textType.getMaxLength())); widget.setLabel(new Model(textType.getFieldName())); return widget; } } Now the problem: Wicket complains that my TextFieldDecorator is not serializable. But why? IMO it is not added to the component hierarchy. The argument to the panel.add(...) method is the result of evaluating: WidgetDecorator.decorate(name).from(person.getName(), which returns the TextField widget. Should I redo my Java programmers exam? Thanx, -- Martijn Lindhout JointEffort IT Services http://www.jointeffort.nl [EMAIL PROTECTED] +31 (0)6 18 47 25 29