getting setting images for contact

8 views
Skip to first unread message

lorenzov...@gmail.com

unread,
Sep 23, 2015, 4:23:13 AM9/23/15
to CodenameOne Discussions
Hi all, is there an example or something for sending getting images via REST web service (i'm using jersey and tomcat)
For now i successfully implemented all the methods for getting contact firstname, lastname, number...(not yet using a db but soon i will) i really would enjoy getting images for the contact, i post my ws:

@Path("/jsonServices")
public class JerseyRestService {
public ArrayList<Student> Rubrica=new ArrayList<Student>();

    @GET
    @Path("/print/{name}")
    @Produces(MediaType.APPLICATION_JSON)
    public ArrayList<Student> produceJSON( @PathParam("name") String name ) {
        setRubrica();
       
        ArrayList<Student> Risultati=new ArrayList<Student>();
        int cc=1;
        for(int i=0; i< Rubrica.size();i++){
            String nome=Rubrica.get(i).getFirstName();
            String cognome=Rubrica.get(i).getLastName();
            name=name.toUpperCase();
            if(Rubrica.get(i).getFirstName().toUpperCase().equals(name)|| Rubrica.get(i).getLastName().toUpperCase().equals(name))
            {
                Risultati.add(Rubrica.get(i));
            }
           
        }   
        return Risultati;
    }
   
    @GET
    @Path("/print")
    @Produces(MediaType.APPLICATION_JSON)
    public ArrayList<Student> rubica() {
        setRubrica();
        return Rubrica;

    }
public void setRubrica(){
    Rubrica.add(new Student("Lorenzo","Volponi",27,1,"0712811157"));
    Rubrica.add(new Student("Alberto","Volponi",60,2,"0712811157"));
    Rubrica.add(new Student("Simonetta","Ferretti",60,3,"0712811157"));
    Rubrica.add(new Student("Federico","Volponi",37,4,"0712811157"));
    Rubrica.add(new Student("Piero","Bernardelli",27,5,"0712811157"));
    Rubrica.add(new Student("Gian Piero","Surace",60,6,"0712811157"));
    Rubrica.add(new Student("ilenia","falcioni",60,7,"0712811157"));
    Rubrica.add(new Student("Laura","Sacchetti",26,8,"0712811157"));

}

Thank you!

Shai Almog

unread,
Sep 23, 2015, 10:38:10 PM9/23/15
to CodenameOne Discussions, lorenzov...@gmail.com
Hi,
yes:
https://www.udemy.com/build-mobile-ios-apps-in-java-using-codename-one/

I would suggest doing what Facebook/Google do... Returning an id within the JSON from which you can assemble a URL easily e.g.:
http://myserver/GetImage?density=t&id=myId

Then you can use that URL directly in URLImage or anywhere in the app and the server will deliver the right sized image for you.
Reply all
Reply to author
Forward
0 new messages