I want to make the DB object be created only when it's required, so I want to do something like this
public class Data {
public List<Group> getGroups(){
List<Group> MyList=new ArrayList<Group>();
Connection conn=null;
@ManagedProperty(value = "#{myConnection}")
myConnection getCon;
}
But that doesn't work, Instead I have to do it like this
public class Data {
@ManagedProperty(value = "#{myConnection}")
myConnection getCon;
public List<Group> getGroups(){
List<Group> MyList=new ArrayList<Group>();
Connection conn=null;
}
Why can't I make a managedProperty inside the function ? I thought about it and it should be okay to be outside since it'll be created when I create the object but is there anyway to make it inside the function ?
Aucun commentaire:
Enregistrer un commentaire