Some problems with the form navigation (back)

69 views
Skip to first unread message

asaf...@gmail.com

unread,
Jul 1, 2014, 5:56:35 PM7/1/14
to codenameone...@googlegroups.com
*first, I am new to Codename One

If you are experiencing an issue please mention the full platform your issue applies to:

1. when I use the setHomeForm, every time I navigate to the form, after traveling some forms, it wont let me go back to the older history.
2. I have a splash form, that calls another form, this form can request data and open the same form (multiple times), when I try to go back it wont navigate back.
3. *this issue is very strange, splash screen -> open form A and disable the go back to the splash form overriding allowBackTo -> open form B
-> open form B -> open form B -> open form B (repeat several times) -> go back (esc or the hardware key)
I will go to form A, -> back -> form B (several times) -> back -> from A -> not going back to splash.
4. when I open the same form and update a label by using findLabel().setText(), it will only update the same form and not the current.


IDE: NetBeans/Eclipse/IDEA
Eclipse, Simulator 

Shai Almog

unread,
Jul 2, 2014, 1:43:45 AM7/2/14
to codenameone...@googlegroups.com, asaf...@gmail.com
Hi,
This is the main purpose of the home form. This means its the main form of your application from which you don't have a back command other than to minimize the application (on devices such as Android).

I'm not sure I understand the layout of your application in terms of navigation? Do you want your home form to have a back command? If so where would it lead to?
You can just set the home form to a dummy form name and it would probably work as you expect.

Try using findLabel(formInstance)

asaf...@gmail.com

unread,
Jul 2, 2014, 4:35:31 AM7/2/14
to codenameone...@googlegroups.com, asaf...@gmail.com
Thank you for the reply.

each one of them describe a diff scenario.
1. is the scenario of which -  I setHomeForm, and open multiple forms one after another and then I showForm, tyhe same as I as the one I set home at the beginning, 
I cant go back from this, (I understand from your answer that this is ok).

2. a splash form called another form and setHomeForm the new one, if this form create multiple times the same form with diff data, I cant go back to the prev forms
(I understand from your answer that this is ok).

3. splash form open form A, and I override the allowBackTo to not allow to go to the splash form, form A open form B, form B can open a new Form B (recursively).
The first time I click the back key, for some strange reason the form A is there, than it goes back to all the B forms, than to the original from A, I cant go to the splash which is correct.
(the problem here is that I dont understand why form A is there on the first back)

4. your answer solve the problem.

Thank You
Asaf

asaf...@gmail.com

unread,
Jul 2, 2014, 4:58:57 AM7/2/14
to codenameone...@googlegroups.com, asaf...@gmail.com
one more thing about the 2nd scenario, it is also happens when I didnt use the setHomeForm.
I override the allowBackTo, I show Form A from Form A multiple times. but the back is not working.

Shai Almog

unread,
Jul 2, 2014, 10:33:36 AM7/2/14
to codenameone...@googlegroups.com, asaf...@gmail.com
Hi,
2. Can you provide specific details? What is the allowBackTo referring to? If it refers to the previous form then back wouldn't show.

3. How do your navigate from form B to the second instance of form B?

asaf...@gmail.com

unread,
Jul 2, 2014, 10:42:54 AM7/2/14
to codenameone...@googlegroups.com, asaf...@gmail.com
2. I override the allowBackTo function, and I check if the for is "ViewSplash", if equals I return false, otherwise the super.allowBackTo .

3.  on Form B I have a command and it action is showForm("FormB", null);
I would like to show the same form with diff data on it, and when someone press the back button I will want him to see the prev data.
its like paging throw the activities.
If I am wrong on the flow, please explain the correct flow.
 
P.S:
the interesting about it, when I go from the splash to Form A, and I set the allowBackTo return false, I have a fill view,
when I go to Form B, I have a blue line at the bottom (no title set) and no back button appear.
when I fo to form B again, I have this blue line (this can repeat forever)
when I press the back, I get Form A with the blue line
multiple backs will show Form B, with a blue line at the bottom
when I go back to form A, he is in full screen with no blue line.




Shai Almog

unread,
Jul 3, 2014, 12:02:16 AM7/3/14
to codenameone...@googlegroups.com, asaf...@gmail.com
There is a method called:
protected boolean isSameBackDestination(Container source, Container destination);

That is designed to create exactly this behavior. It intentionally skips form B's to go back to form A. Just override it to always return false and disable that behavior.

Can you provide a screenshot of the blue line, its hard to understand what you are referring to.

asaf...@gmail.com

unread,
Jul 8, 2014, 5:21:04 PM7/8/14
to codenameone...@googlegroups.com, asaf...@gmail.com


Shai Almog

unread,
Jul 9, 2014, 12:56:33 AM7/9/14
to codenameone...@googlegroups.com, asaf...@gmail.com
That's a command, if you don't have a title commands are added there instead.
Just don't add the details command in the form where you don't have a title.
Reply all
Reply to author
Forward
0 new messages