02-05-2009 09:11 AM
Hi all.
I am trying to replace a field of my screen and have done it already:
fOriginalField.getManager().replace(fOriginalField
But now I cannot do the opposite (I want to return it to its original state). I get a null pointer exception when I try that.
fOriginalField.getManager().replace(fNewField, fOriginalField); -> null pointer exception !
Should this work ? I know that the replacement field must not belong to any manager, and I believe that causes the mess. Am I right ?
Or some intermediate code messes up with this procedure ?
Solved! Go to Solution.
02-05-2009 09:33 AM
02-05-2009 09:37 AM - edited 02-05-2009 09:37 AM
Yes,
Silly I was just writing a reply to this thread explaining what a stupid thing I did, when I got an email with your reply.
Thanks for your interest
and kind explanation
02-03-2010 04:12 AM
Hi to all!
I have the exact same problem.
But I am not so good in english!
Can you tell me how to solve it please?
02-03-2010 04:17 AM
hello rentepatrick,
please create an own thread for your question as this topic is already solved. did you try the solution already?
02-03-2010 04:30 AM
hi,
the problem is that I don't understant de solution.
Best regards
02-03-2010 04:33 AM
if you remove a field from a manager this field now is not added to a manager. because you removed it.
if you call getManager on the field you get null. because it is not added to a manager.
if you try to do some operation on this non-existing manager you get a nullpointerexception. you can avoid this if you check for getManager returning null or change the logic of the code.
02-03-2010 04:37 AM
Thank you for your reply!
I have this:
public void fieldChanged(Field field, int context) {
// TODO Auto-generated method stub
if(field == lst_City.typeField){
String s_Type = (String)lst_City.typeField.getChoice(lst_City.type
s_Type = s_Type.toLowerCase();
lst_City.constructRestList(s_Type);
if(lst_City.typeField.getSelectedIndex()==0){
lst_City.filteredRestListField.getManager().repla
}
UiApplication.getUiApplication().invokeLater (new Runnable() {
public void run()
{
//Perform screen changes here.
// replace(lst_City.restListField, lst_City.filteredRestListField);
lst_City.restListField.getManager().replace(lst_Ci
lst_City.restListField = lst_City.filteredRestListField;
02-03-2010 04:44 AM
i also try this, I changed my code as you sugested and didn't work.
public void fieldChanged(Field field, int context) {
// TODO Auto-generated method stub
if(field == lst_City.typeField){
String s_Type = (String)lst_City.typeField.getChoice(lst_City.type
s_Type = s_Type.toLowerCase();
lst_City.constructRestList(s_Type);
if(lst_City.typeField.getSelectedIndex()==0){
l st_City.filteredRestListField = lst_City.restListField;
}
UiApplication.getUiApplication().invokeLater (new Runnable() {
public void run()
{
//Perform screen changes here.
lst_City.restListField.getManager().replace(lst_Ci
lst_City.restListField = lst_City.filteredRestListField;
//Calling invalidate() on your screen forces the paint
//method to be called.
//invalidate();
}
Please help me.