Ask questions and see you at 3rd August at 6.PM. CET: http://www.ustream.tv/channel/adambien Also see archives: airhacks.tv
Created
July 7, 2015 05:40
-
-
Save AdamBien/a0fedea018c96f43f33a to your computer and use it in GitHub Desktop.
17thAirhacksQ&A
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, Im new to JAX-RS approach and i've a particular questions. can anybody answer?
I've a method like following in a service class
@GET @Produces(MediaType.APPLICATION_JSON) public Response listUsers( //PaginatedListWrapper @QueryParam("page") @DefaultValue("1") Integer page, @QueryParam("sortFields") @DefaultValue("id") String sortFields, @QueryParam("sortDirections") @DefaultValue("asc") String sortDirections) { PaginatedListWrapper listWrapper = new PaginatedListWrapper<>(); listWrapper.setCurrentPage(page); listWrapper.setSortFields(sortFields); listWrapper.setSortDirections(sortDirections); listWrapper.setTotalResults(this.countAll()); int start = (listWrapper.getCurrentPage() - 1) * listWrapper.getPageSize(); listWrapper.setList(userFacade.findRange(new int[]{start, listWrapper.getPageSize()})); return Response.status(Response.Status.OK).entity(listWrapper).build(); }my PaginatedListWrapper class like follows
public class PaginatedListWrapper { private Integer currentPage; private Integer pageSize; private Integer totalResults; private String sortFields; private String sortDirections; private List list;and im getting output like the following
Object { currentPage: 1, list: Array[2], 0: "net.brac.ict.mis.tup.uplift.business.entities.User[ id=1 ]" 1: "net.brac.ict.mis.tup.uplift.business.entities.User[ id=2 ]" pageSize: 10, sortDirections: "asc", sortFields: "id"… }why im not getting the list of users as json object? like array of objects [{}, {}, {} ...]
what im missing here?
other than using jersey or jackson, i want to learn the underneath core stuffs of doing this.
in my maven it just javaee-web-api and eclipselink