Re: [codenameone-discussions] why my function is always returning null object

2017-04-26 Thread steve nganga
Share the stacktrace... just from looking at your code you have already
instantiated Membre on the first line and hence does not make sense to
return null;

On Wed, Apr 26, 2017 at 4:27 AM, b.wassim Rmd 
wrote:

> If you are experiencing an issue please mention the full platform your
> issue applies to:
> IDE: NetBeans
> Simulator
>
> --
> You received this message because you are subscribed to the Google Groups
> "CodenameOne Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to codenameone-discussions+unsubscr...@googlegroups.com.
> Visit this group at https://groups.google.com/
> group/codenameone-discussions.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/codenameone-discussions/162dbb4a-994b-40c8-a3af-
> acab803b928f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/CAOfyKqZGLn_F0SpV3iWoBzy%3DhMWfQJGzzTR0PTsdcfx_t%2B3%2B_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[codenameone-discussions] why my function is always returning null object

2017-04-25 Thread b.wassim Rmd
If you are experiencing an issue please mention the full platform your 
issue applies to:
IDE: NetBeans
Simulator 

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to codenameone-discussions+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/162dbb4a-994b-40c8-a3af-acab803b928f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package serviceImpl;

import com.codename1.io.CharArrayReader;
import com.codename1.io.ConnectionRequest;
import com.codename1.io.JSONParser;
import com.codename1.io.NetworkEvent;
import com.codename1.io.NetworkManager;
import com.codename1.ui.events.ActionListener;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import model.Membre;

/**
 *
 * @author wassim
 */
public class MembreService {

public Membre me ;
public Membre aux;
public MembreService() {
}

 

public Membre getPubMember(int id) {
   me  = new Membre();

ConnectionRequest con = new ConnectionRequest();
con.setUrl("http://localhost/piService/getUserById.php?userId=; + id);

con.addResponseListener(new ActionListener() {
@Override
public void actionPerformed(NetworkEvent evt) {
try {

JSONParser j = new JSONParser();
Map users = j.parseJSON(new CharArrayReader(new String(con.getResponseData()).toCharArray()));
Map obj = (Map) users.get("users");
me.setId(Integer.parseInt(obj.get("id").toString()));
me.setUsername(obj.get("username").toString());
me.setEmail(obj.get("email").toString());
me.setAge(Integer.parseInt(obj.get("age").toString()));
me.setNom(obj.get("nom").toString());
me.setPrenom(obj.get("prenom").toString());
me.setProfil_pic(obj.get("profile_pic").toString());
aux = me;

} catch (IOException ex) {
//Logger.getLogger(MembreService.class.getName()).log(Level.SEVERE, null, ex);
}

}
});
//NetworkManager.getInstance().addToQueue(con);
System.out.println(aux);
return me;

}

}