Does your code compile? JSONSerializerListener does not define endList() or 
readItem().

On Dec 9, 2010, at 9:47 PM, [email protected] wrote:

> 
> Sorry for bothering you again. 
> 
> I use JSONSerializer to read ArrayList. 
> 
> Code: 
> 
>                 JSONSerializer jsonSerializer = new JSONSerializer(); 
>                         jsonSerializer.getJSONSerializerListeners().add(new 
> JSONSerializerListener.Adapter(){ 
>                                 private ArrayList<Object> page = new 
> ArrayList<Object>(200); 
>                                   
>                     public void endList(JSONSerializer jsonSerializer) { 
>                        .. 
>                     } 
>                     
>                     public void readItem(JSONSerializer jsonSerializer, 
> Object item) { 
>                         .. 
>                     } 
>                     
>                     public void endDictionary(JSONSerializer jsonSerializer) 
> { 
>                        .. 
>                         }); 
>                 } 
> An exception is thrown out 
> 
>         java.lang.NoSuchMethodError: 
> org.apache.pivot.json.JSONSerializer.getJSONSerializerListeners()Lorg/apache/pivot/util/ListenerList;
>  
> 
> Since I get data from db in a jsp(or from a servlet.). 
>         1.i can't use the callback class 
>         2.from jsonSerializer.getJSONSerializerListeners () throwing error. 
> 
> I am totally stranded.. 
> 
> Looking forward to the reply.Thanks very much 
> 
> Hero. 
> 
> 
> 
> 
> 
> 
> Greg Brown <[email protected]>
> 12/09/2010 09:13 PM
> Please respond to
> [email protected]
> 
> To
> [email protected]
> cc
> Subject
> Re: how to set large data using getquery and jsonserializer?
> 
> 
> 
> 
> 
>         I'd like to build a demo following the large data set sample in 
> Apache Pivot official web site . 
> 
>        The sample is using CSVSerializer and calling a thead class 
> [AddRowsCallback] in method endList() and readitem(). 
> 
> Question: 
>        1.Can any one demonstrate the 2 method of  endList() and readItem()? 
> 
> The code at the beginning of this file is the best example of how to use 
> these methods: 
> 
> http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos/million/LargeData.java
>  
> 
> The execute() method opens a stream from the given URL and wraps it in a 
> MonitoredInputStream. MonitoredInputStream is an inner class of IOTask that 
> will respect the abort flag if it is set by the caller. 
> 
> It then reads the data from the input stream using CSVSerializer. 
> CSVSerializer fires 3 events: 
> 
> beginList() -- called when the list is created 
> endList() -- called after the last item has been read 
> readItem() -- called after each item is read 
> 
> In this example, the listener implementation builds up pages of results 
> before adding them to the table view, since this will generally perform 
> better for a large number of rows. The add is done in a callback so the UI 
> does not get bogged down. 
> 
>         2.if using JSONSerializer and accept  ArrayList parameter.do i still 
> have to overwrite endList() and readItem()?I tried 
>      but it seams wrong. 
> 
> If you are reading JSON data, you will probably want to implement endList() 
> and endDictionary() (assuming that your items are stored as JSON objects). 
> endDictionary() will be called for each "row" in your data set. 
> 
> I just want to set ArrayList  into tableview.As when the list'length is over 
> about 500 hundreds,UI becomes 
> frozen a few minutes. 
> 
> Yes, that is why we use the callback with the listeners. Make sure that you 
> are calling the asynchronous version of Task#execute() (the one that takes a 
> TaskListener). The synchronous one won't do you much good, since you'll be 
> executing the actual query on the UI thread and it won't get any updates 
> until the task is done. 
> 
> 

Reply via email to