<div>
                    +1
                </div>
                <div><div><br></div><div><br></div><div><div>--&nbsp;</div><div>"The measure of a man is what he does with power" - Plato</div><div>-</div><div>@abstractj</div><div>-</div><div>Volenti Nihil Difficile</div></div></div>
                 
                <p style="color: #A0A0A8;">On Thursday, January 10, 2013 at 8:02 AM, Matthias Wessendorf wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div><div>On Thu, Jan 10, 2013 at 10:11 AM, Daniel Bevenius</div><div>&lt;<a href="mailto:daniel.bevenius@gmail.com">daniel.bevenius@gmail.com</a>&gt; wrote:</div><blockquote type="cite"><div><blockquote type="cite"><div><div>For the demo purpose, we could bootstrap the list of cars during startup so</div><div>we don't need to manually add all the cars.</div></div></blockquote><div>Absolutely, that would be no problem.</div></div></blockquote><div><br></div><div>+1 - that would make it easier to test/develop</div><div><br></div><blockquote type="cite"><div><div><br></div><div><br></div><div><br></div><div><br></div><div>On 10 January 2013 10:06, Sebastien Blanc &lt;<a href="mailto:scm.blanc@gmail.com">scm.blanc@gmail.com</a>&gt; wrote:</div><blockquote type="cite"><div><div><br></div><div>Great !</div><div>For the demo purpose, we could bootstrap the list of cars during startup</div><div>so we don't need to manually add all the cars.</div><div>Seb</div><div><br></div><div><br></div><div><br></div><div>On Thu, Jan 10, 2013 at 10:02 AM, Daniel Bevenius</div><div>&lt;<a href="mailto:daniel.bevenius@gmail.com">daniel.bevenius@gmail.com</a>&gt; wrote:</div><blockquote type="cite"><div><div><br></div><div>We talked about paging yesterday on IRC, and it was decided to add a</div><div>paging example to aerogear-controller-demo. What follows is an example to</div><div>kick of further discussion about what the example should look like.</div><div><br></div><div>AeroGear Controller Demo Paging Route</div><div><br></div><div>This page discusses AEROGEAR-795 which is about adding an example to</div><div>aerogear-controller-demo to demonstrate paging support so that the client</div><div>libraries (Android, JavaScript, and iOS) can be tested against it.</div><div><br></div><div>This is only a suggestion and the implementation and the names of the</div><div>query parameters can all be changed.</div><div><br></div><div>Use case</div><div><br></div><div>The example is using cars as the resource to interact with. To be able to</div><div>query we need something to query, so lets start by adding some cars by</div><div>posting.</div><div><br></div><div>Adding Cars</div><div><br></div><div>URL="<a href="http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo">http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo</a>"</div><div><br></div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Black&amp;car.brand=BMW" -X</div><div>POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Red&amp;car.brand=Ferrari"</div><div>-X POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Blue&amp;car.brand=Skoda"</div><div>-X POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Green&amp;car.brand=Audi"</div><div>-X POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Yello&amp;car.brand=Opel"</div><div>-X POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Pink&amp;car.brand=Mini" -X</div><div>POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Gray&amp;car.brand=Nissan"</div><div>-X POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Red&amp;car.brand=Volvo" -X</div><div>POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Blue&amp;car.brand=Saab" -X</div><div>POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Black&amp;car.brand=Mazda"</div><div>-X POST "$URL/cars"</div><div>curl -i --header "Accept: application/json" -H "Content-type:</div><div>application/x-www-form-urlencoded" --data "car.color=Yello&amp;car.brand=Golf"</div><div>-X POST "$URL/cars"</div><div><br></div><div>The example uses an in-memory database so the data will be cleared upon</div><div>redployment/restart of the server. So you only need to populate/post when</div><div>you've restared or redployed.</div><div><br></div><div>With the cars in place, we can now issue GET requests with paging query</div><div>parameters. The following route has been added to the demo:</div><div><br></div><div>route()</div><div>      .from("/cars")</div><div>      .on(RequestMethod.GET)</div><div>      .produces(MediaType.JSON.toString())</div><div>      .to(Cars.class).get(param("page", "0"), param("perPage", "-1"));</div><div><br></div><div>From this we can see that there are two optional parameters, page and</div><div>perPage. If these are not specified all cars will be returned.</div><div><br></div><div>Getting a page of Cars</div><div><br></div><div>URL="<a href="http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo">http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo</a>"</div><div>curl -i --header "Accept: application/json" "$URL/cars?page=0&amp;perPage=4"</div><div><br></div><div>The request will return:</div><div><br></div><div>{</div><div>  "metadata":{"page":0,"perPage":4},</div><div>  "cars":[</div><div>            {"color":"Black","brand":"BMW","id":1},</div><div>            {"color":"Red","brand":"Ferrari","id":2},</div><div>            {"color":"Blue","brand":"Skoda","id":3},</div><div>            {"color":"Green","brand":"Audi","id":4}</div><div>          ],</div><div>  "links":{</div><div>          "first":"cars?page=0&amp;page=4",</div><div>          "previous":"cars?page=0&amp;page=4",</div><div>          "next":"cars?page=1&amp;page=4"</div><div>          }</div><div>}</div><div><br></div><div>Getting the next page of Cars</div><div><br></div><div>To get the next page you can follow the next link:</div><div><br></div><div>URL="<a href="http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo">http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo</a>"</div><div>curl -i --header "Accept: application/json" "$URL/cars?page=1&amp;perPage=4"</div><div><br></div><div>{</div><div>    "metadata":{"page":1,"perPage":4},</div><div>    "cars":[</div><div>            {"color":"Yello","brand":"Opel","id":5},</div><div>            {"color":"Pink","brand":"Mini","id":6},</div><div>            {"color":"Gray","brand":"Nissan","id":7},</div><div>            {"color":"Red","brand":"Volvo","id":8}</div><div>           ],</div><div>    "links":{</div><div>            "first":"cars?page=0&amp;page=4",</div><div>            "previous":"cars?page=0&amp;page=4",</div><div>            "next":"cars?page=2&amp;page=4"</div><div>            }</div><div>}</div><div><br></div><div>Get all Cars</div><div><br></div><div>URL="<a href="http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo">http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo</a>"</div><div>curl -i --header "Accept: application/json" "$URL/cars"</div><div><br></div><div>Get a single Car</div><div><br></div><div>URL="<a href="http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo">http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo</a>"</div><div>curl -i --header "Accept: application/json" "$URL/cars/1"</div><div><br></div><div>The request will return:</div><div><br></div><div>{"color":"Black","brand":"BMW","id":1}</div><div><br></div><div>Again, anything here can be changed, the name of the query parameters,</div><div>the implementation, and what is returned.</div><div><br></div><div>Reference:</div><div><br></div><div>Paging Support in AeroGear Controller</div><div><br></div><div><br></div><div>_______________________________________________</div><div>aerogear-dev mailing list</div><div><a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a></div><div><a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></div></div></blockquote><div><br></div><div><br></div><div>_______________________________________________</div><div>aerogear-dev mailing list</div><div><a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a></div><div><a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></div></div></blockquote><div><br></div><div><br></div><div>_______________________________________________</div><div>aerogear-dev mailing list</div><div><a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a></div><div><a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></div></div></blockquote><div><br></div><div><br></div><div><br></div><div>-- </div><div>Matthias Wessendorf</div><div><br></div><div>blog: <a href="http://matthiaswessendorf.wordpress.com">http://matthiaswessendorf.wordpress.com</a>/</div><div>sessions: <a href="http://www.slideshare.net/mwessendorf">http://www.slideshare.net/mwessendorf</a></div><div>twitter: <a href="http://twitter.com/mwessendorf">http://twitter.com/mwessendorf</a></div><div>_______________________________________________</div><div>aerogear-dev mailing list</div><div><a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a></div><div><a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></div></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>