PDA

View Full Version : server implementation on paging grid



haibin
15 Jan 2009, 8:33 PM
Hi,

I'm looking at the Paging Grid example and have a question on the server implementation.

In ExampleServiceImpl class



private List<Post> posts;

public PagingLoadResult<Post> getPosts(final PagingLoadConfig config) {
if (posts == null) {
loadPosts();
}

// ignore the rest
}
I thought posts will always be null every time a new thread is instantiated. In my own implementation, class variables do get set to null ever time. But it seems to be working fine in the demo explorer. Any idea why?

vanderbill
16 Jan 2009, 9:20 AM
look the code in examples, there are server side code paging implementation
:D:D:D:D:D

haibin
16 Jan 2009, 5:01 PM
Yes, I code I posted above is from the examples.

EagleEye666666
17 Jan 2009, 3:32 AM
Yes, I code I posted above is from the examples.

I would like to help but i did not get ur question. Just not understanding it.

haibin
18 Jan 2009, 10:17 AM
My understanding is if servlet is started in a new thread, then

if (posts == null)

will always be true. So loadPost() will be called every time when users click on Next Page on the paging tool. Obviously it should not be the case. What's wrong with my understanding?

gslender
19 Jan 2009, 2:43 PM
My understanding is if servlet is started in a new thread, then

if (posts == null)

will always be true. So loadPost() will be called every time when users click on Next Page on the paging tool. Obviously it should not be the case. What's wrong with my understanding?

Servlets are session based - so this only happens per client instance, not per request.

haibin
19 Jan 2009, 7:55 PM
I see. Thanks for your help.

But where can I see those codes that handle sessions? I was looking for something like

this.getThreadLocalRequest().getSession();

in the ExampleServiceImpl.java

gslender
19 Jan 2009, 8:02 PM
ExampleServiceImpl extends RemoteServiceServlet, which extends HttpServlet

This is a fundamental Servlet function where data is persistent.

Read this -> http://www.novocode.com/doc/servlet-essentials/chapter1.html