I've some question about the sample code:
1. How to retrieve the list of customers/users ?
2. What type must I use (ArrayList, Set, List, act...) ?
Because I try to retrieve a list but I got an exception
java.lang.NoClassDefFoundError: com/sun/syndication/feed/synd/SyndFeed
My code
Server side
public interface RootControllerResource {
@Get
ArrayList findAll();
}
public class RootController extends ServerResource implements
RootControllerResource {
private ArrayList users;
public RootController() {
super();
// Generate some sample data
this.users = new ArrayList();
users.add(new User(1, "user1", "user_f", "user_l", 26));
users.add(new User(2, "user2", "user_f", "user_l", 24));
}
@Override
public ArrayList findAll() {
return users;
}
}
JEE Client
public class Client {
/**
* @param args
*/
public static void main(String[] args) {
ClientResource cr = new ClientResource("// uri //");
RootControllerResource rcr =
cr.wrap(RootControllerResource.class);
ArrayList users = rcr.findAll();
for (User u : users){
System.out.println(u.userid);
System.out.println(u.username);
System.out.println(u.firstname);
System.out.println(u.lastname);
System.out.println(u.age);
}
try {
// Try to get the json representation
cr.get(MediaType.APPLICATION_JSON).write(System.out);
} catch (ResourceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Say me if it's a good way.
Best regards
--
View this message in context:
http://restlet-discuss.1400322.n2.nabble.com/ClientResource-Examples-tp3506100p7288837.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2923029