I am trying to add a list to the VerticalFieldManager , and then this manager to another VerticalFieldManager . I use it in custom tabs. The first time the application starts, it works fine, but when I switch to another tab and return to it, it gives IllegalStateException .
I tried this in many ways, but did not get what throws an exception when adding a VerticalFieldManager.
I am using the code:
This code is for a tab that has two sub tabs. For sub-tabs, it works fine, but not for the main tab.
There is another scenario where GetConnectedFriendsInterMediater is called in which I add a list to friendsVFM that throws an exception. Code for this:
GetConnectedFriendsWebService getFriendsWebService = new GetConnectedFriendsWebService(method ,userName); Vector friendsVecList= getFriendsWebService.getFriends(); Constants.connectedUsersVector = friendsVecList ; synchronized (UiApplication.getEventLock()) { if(TabControlScreen.friendsVFM.getFieldCount()!=0){ TabControlScreen.friendsVFM.deleteAll(); } TabControlScreen.friendsVFM.add(ConnectedFriends.getInstance(KingdomConnectMain.buddyList));
I solved the problem when I switched the tab, I did not create a new instance for friendsVFM and used the same instance that was throwing an exception at the time. Now this is the same exception when I try to add a buddyList to _listVFM . I know this has to do with adding buddyList again, which has already been added. Is there any solution so that I can add a list without exception. Code for this:
// CREATE A SINGLE BUDDYLIST SCREEN GUIDE
public static ConnectedFriends getInstance(BuddyListField buddyListField){ if(connectedFriends==null){ connectedFriends = new ConnectedFriends(buddyListField); } return connectedFriends; } public ConnectedFriends(BuddyListField buddyListField) { if(_listVFM!=null){ _listVFM.deleteAll(); } _listVFM = new VerticalFieldManager(); _listVFM.add(buddyListField);
When I return from another tab to the sam tab, it throws an exception or, in other words, I cannot add a list.