Best way to work with the iterator of IDataProvider
Hi, I would like to know what is the best way to work with the method iterator of DataProvider. I have created a class implementing IDataProvider. Depending of a parameter, the DAO service called is not the same inside in the iterator method. For some DAO services, a list is returned but for one service, an object is returned instead of a list. If I try to create a ArrayList inside the iterator, the following error is generated : org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: java.util.AbstractList$Itr Field hierarchy is: 0 [class=com.xpectis.x3s.fundbox.web.RequestPage, path=0] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[3] [class=com.xpectis.x3s.fundbox.web.RequestPage$1, path=0:requestList] private final org.apache.wicket.markup.repeater.data.IDataProvider org.apache.wicket.markup.repeater.data.DataViewBase.dataProvider [class=com.xpectis.x3s.fundbox.web.data.RequestProvider] private java.util.Iterator com.xpectis.x3s.fundbox.web.data.RequestProvider.it [class=java.util.AbstractList$Itr] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:346) How can I avoid this issue ? Here is my code : public class RequestProvider implements IDataProvider { ... public Iterator iterator(int first, int count) { result = new ArrayListPlatformDTO(); if (requestFormModel != null) { if (requestFormModel.getId() != null) { request = requestService.getRequest(requestFormModel.getId()); result.add(request); it = result.iterator(); } else if (requestFormModel.getFileName() != null) { it = requestService.findRequestByFileName(requestFormModel.getFileName()).iterator(); } Regards, Charles Moulliard Senior Enterprise Architect Apache Camel Committer * blog : http://cmoulliard.blogspot.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Best way to work with the iterator of IDataProvider
I see several undefined objects: result requestFormModel it If these are defined at the class level, they must be serializable. If you have Logging set at Info, Wicket will give you the actual field that is not serializable, although from the error it looks like something to do with AbstractList Iterator objects are not serializable. I would look at how you are defining the it variable. On Mon, Sep 28, 2009 at 7:25 AM, Charles Moulliard cmoulli...@gmail.comwrote: Hi, I would like to know what is the best way to work with the method iterator of DataProvider. I have created a class implementing IDataProvider. Depending of a parameter, the DAO service called is not the same inside in the iterator method. For some DAO services, a list is returned but for one service, an object is returned instead of a list. If I try to create a ArrayList inside the iterator, the following error is generated : org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: java.util.AbstractList$Itr Field hierarchy is: 0 [class=com.xpectis.x3s.fundbox.web.RequestPage, path=0] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[3] [class=com.xpectis.x3s.fundbox.web.RequestPage$1, path=0:requestList] private final org.apache.wicket.markup.repeater.data.IDataProvider org.apache.wicket.markup.repeater.data.DataViewBase.dataProvider [class=com.xpectis.x3s.fundbox.web.data.RequestProvider] private java.util.Iterator com.xpectis.x3s.fundbox.web.data.RequestProvider.it [class=java.util.AbstractList$Itr] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:346) How can I avoid this issue ? Here is my code : public class RequestProvider implements IDataProvider { ... public Iterator iterator(int first, int count) { result = new ArrayListPlatformDTO(); if (requestFormModel != null) { if (requestFormModel.getId() != null) { request = requestService.getRequest(requestFormModel.getId()); result.add(request); it = result.iterator(); } else if (requestFormModel.getFileName() != null) { it = requestService.findRequestByFileName(requestFormModel.getFileName()).iterator(); } Regards, Charles Moulliard Senior Enterprise Architect Apache Camel Committer * blog : http://cmoulliard.blogspot.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Best way to work with the iterator of IDataProvider
Further, you don't really need to define the Iterator, just return them. public Iterator iterator(int first, int count) { result = new ArrayListPlatformDTO(); if (requestFormModel != null) { if (requestFormModel.getId() != null) { request = requestService.getRequest(requestFormModel.getId()); result.add(request); return result.iterator(); } else if (requestFormModel.getFileName() != null) { return requestService.findRequestByFileName(requestFormModel.getFileName()).iterator(); On Mon, Sep 28, 2009 at 9:08 AM, T Ames tamesw...@gmail.com wrote: I see several undefined objects: result requestFormModel it If these are defined at the class level, they must be serializable. If you have Logging set at Info, Wicket will give you the actual field that is not serializable, although from the error it looks like something to do with AbstractList Iterator objects are not serializable. I would look at how you are defining the it variable. On Mon, Sep 28, 2009 at 7:25 AM, Charles Moulliard cmoulli...@gmail.comwrote: Hi, I would like to know what is the best way to work with the method iterator of DataProvider. I have created a class implementing IDataProvider. Depending of a parameter, the DAO service called is not the same inside in the iterator method. For some DAO services, a list is returned but for one service, an object is returned instead of a list. If I try to create a ArrayList inside the iterator, the following error is generated : org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: java.util.AbstractList$Itr Field hierarchy is: 0 [class=com.xpectis.x3s.fundbox.web.RequestPage, path=0] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[3] [class=com.xpectis.x3s.fundbox.web.RequestPage$1, path=0:requestList] private final org.apache.wicket.markup.repeater.data.IDataProvider org.apache.wicket.markup.repeater.data.DataViewBase.dataProvider [class=com.xpectis.x3s.fundbox.web.data.RequestProvider] private java.util.Iterator com.xpectis.x3s.fundbox.web.data.RequestProvider.it [class=java.util.AbstractList$Itr] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:346) How can I avoid this issue ? Here is my code : public class RequestProvider implements IDataProvider { ... public Iterator iterator(int first, int count) { result = new ArrayListPlatformDTO(); if (requestFormModel != null) { if (requestFormModel.getId() != null) { request = requestService.getRequest(requestFormModel.getId()); result.add(request); it = result.iterator(); } else if (requestFormModel.getFileName() != null) { it = requestService.findRequestByFileName(requestFormModel.getFileName()).iterator(); } Regards, Charles Moulliard Senior Enterprise Architect Apache Camel Committer * blog : http://cmoulliard.blogspot.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Best way to work with the iterator of IDataProvider
Iterator is not serializable, wicket will try to serialize it if it's at class level so either move it inside iterator method or make it transient , In your case,you can easily move it inside method ;) -- regards, Vineet Semwal On Mon, Sep 28, 2009 at 6:42 PM, T Ames tamesw...@gmail.com wrote: Further, you don't really need to define the Iterator, just return them. public Iterator iterator(int first, int count) { result = new ArrayListPlatformDTO(); if (requestFormModel != null) { if (requestFormModel.getId() != null) { request = requestService.getRequest(requestFormModel.getId()); result.add(request); return result.iterator(); } else if (requestFormModel.getFileName() != null) { return requestService.findRequestByFileName(requestFormModel.getFileName()).iterator(); On Mon, Sep 28, 2009 at 9:08 AM, T Ames tamesw...@gmail.com wrote: I see several undefined objects: result requestFormModel it If these are defined at the class level, they must be serializable. If you have Logging set at Info, Wicket will give you the actual field that is not serializable, although from the error it looks like something to do with AbstractList Iterator objects are not serializable. I would look at how you are defining the it variable. On Mon, Sep 28, 2009 at 7:25 AM, Charles Moulliard cmoulli...@gmail.com wrote: Hi, I would like to know what is the best way to work with the method iterator of DataProvider. I have created a class implementing IDataProvider. Depending of a parameter, the DAO service called is not the same inside in the iterator method. For some DAO services, a list is returned but for one service, an object is returned instead of a list. If I try to create a ArrayList inside the iterator, the following error is generated : org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: java.util.AbstractList$Itr Field hierarchy is: 0 [class=com.xpectis.x3s.fundbox.web.RequestPage, path=0] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[3] [class=com.xpectis.x3s.fundbox.web.RequestPage$1, path=0:requestList] private final org.apache.wicket.markup.repeater.data.IDataProvider org.apache.wicket.markup.repeater.data.DataViewBase.dataProvider [class=com.xpectis.x3s.fundbox.web.data.RequestProvider] private java.util.Iterator com.xpectis.x3s.fundbox.web.data.RequestProvider.it [class=java.util.AbstractList$Itr] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:346) How can I avoid this issue ? Here is my code : public class RequestProvider implements IDataProvider { ... public Iterator iterator(int first, int count) { result = new ArrayListPlatformDTO(); if (requestFormModel != null) { if (requestFormModel.getId() != null) { request = requestService.getRequest(requestFormModel.getId()); result.add(request); it = result.iterator(); } else if (requestFormModel.getFileName() != null) { it = requestService.findRequestByFileName(requestFormModel.getFileName()).iterator(); } Regards, Charles Moulliard Senior Enterprise Architect Apache Camel Committer * blog : http://cmoulliard.blogspot.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Best way to work with the iterator of IDataProvider
I have found the error. List Result = new ArrayListPlatformDTO(); must be defined outside of the iterator method and also the answer to my question. When the result is empty or null, then I must return a null iterator T Ames wrote: I see several undefined objects: result requestFormModel it If these are defined at the class level, they must be serializable. If you have Logging set at Info, Wicket will give you the actual field that is not serializable, although from the error it looks like something to do with AbstractList Iterator objects are not serializable. I would look at how you are defining the it variable. On Mon, Sep 28, 2009 at 7:25 AM, Charles Moulliard cmoulli...@gmail.comwrote: Hi, I would like to know what is the best way to work with the method iterator of DataProvider. I have created a class implementing IDataProvider. Depending of a parameter, the DAO service called is not the same inside in the iterator method. For some DAO services, a list is returned but for one service, an object is returned instead of a list. If I try to create a ArrayList inside the iterator, the following error is generated : org.apache.wicket.util.io.SerializableChecker$WicketNotSerializableException: Unable to serialize class: java.util.AbstractList$Itr Field hierarchy is: 0 [class=com.xpectis.x3s.fundbox.web.RequestPage, path=0] private java.lang.Object org.apache.wicket.MarkupContainer.children [class=[Ljava.lang.Object;] java.lang.Object org.apache.wicket.Component.data[3] [class=com.xpectis.x3s.fundbox.web.RequestPage$1, path=0:requestList] private final org.apache.wicket.markup.repeater.data.IDataProvider org.apache.wicket.markup.repeater.data.DataViewBase.dataProvider [class=com.xpectis.x3s.fundbox.web.data.RequestProvider] private java.util.Iterator com.xpectis.x3s.fundbox.web.data.RequestProvider.it [class=java.util.AbstractList$Itr] - field that is not serializable at org.apache.wicket.util.io.SerializableChecker.check(SerializableChecker.java:346) How can I avoid this issue ? Here is my code : public class RequestProvider implements IDataProvider { ... public Iterator iterator(int first, int count) { result = new ArrayListPlatformDTO(); if (requestFormModel != null) { if (requestFormModel.getId() != null) { request = requestService.getRequest(requestFormModel.getId()); result.add(request); it = result.iterator(); } else if (requestFormModel.getFileName() != null) { it = requestService.findRequestByFileName(requestFormModel.getFileName()).iterator(); } Regards, Charles Moulliard Senior Enterprise Architect Apache Camel Committer * blog : http://cmoulliard.blogspot.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - Charles Moulliard SOA Architect My Blog : http://cmoulliard.blogspot.com/ http://cmoulliard.blogspot.com/ -- View this message in context: http://www.nabble.com/Best-way-to-work-with-the-iterator-of-IDataProvider-tp25644122p25645386.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