How to manipulate the back command manually?

102 views
Skip to first unread message

mikko.nu...@gmail.com

unread,
Feb 4, 2015, 7:02:04 AM2/4/15
to codenameone...@googlegroups.com
Hello again,

I have a situation where I should manipulate the back command somehow. I have an insert view that is accessed from list view and the result of insertion is naturally new object that is shown in it's own view. In other words: "List of objects" --> "Insert New Object" --> "Object". Now when the insertion is complete and object's view is shown, the back button reverses: "Object" --> "Insert New Object" --> "List of Objects" which of course is how the application sees it. But the way I want it to be is "Object" --> "List of Objects" after insertion. Is there a way manipulate the system so that I could implement this or more complex situations? I guess the previous form form lives in form itself and it is not so easy since we dont always know which form to back?

Shai Almog

unread,
Feb 4, 2015, 11:41:50 AM2/4/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Hi,
sure. You can use setBackDestination to a form name that's in the stack in order to skip redundant stages.

mikko.nu...@gmail.com

unread,
Feb 5, 2015, 10:45:06 AM2/5/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Okay,

thank you... but when / where should I actually invoke it? My stack was following: "Customer" --> "Visits" --> "Insert Visit" --> "Visit". I added the attached code line to before show method of "Visit" form. But then the reversed stack was "Visit" --> "Insert Visit" --> "Customer"... so something funny happened and "Visits" disappeared completely. I saw with debugger that it did remove "Insert Visit" from baseFormNavigationStack but back button got messed up obviously. It worked with "Customer" --> "Visits" --> "Visit" ("Visit" --> "Visits" etc.) but baseFormNavigationStack is never touched since "Visits" is naturally a top of it.

setBackDestination("Visits");

Shai Almog

unread,
Feb 5, 2015, 12:11:38 PM2/5/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
You should invoke it in the before show of the form where you want the back to behave differently.

mikko.nu...@gmail.com

unread,
Feb 6, 2015, 4:50:48 AM2/6/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
I did that, worked the way I described... a bug?

Shai Almog

unread,
Feb 6, 2015, 11:28:45 AM2/6/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Are you using the form name or the form title?
setBackDestination just unwinds the stack of the navigation, its pretty simple.

mikko.nu...@gmail.com

unread,
Feb 7, 2015, 11:07:34 AM2/7/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Form name, they both are identical though. As said, I saw with debugger that the stack was successfully altered... but the back-button still showed the form it should've skipped.

Shai Almog

unread,
Feb 7, 2015, 11:31:01 AM2/7/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
I see a problem there, not sure when it cropped up. Can you please file an issue on this?

mikko.nu...@gmail.com

unread,
Feb 9, 2015, 4:28:36 AM2/9/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Sure, about third issue in a month :P. Are you going to buy me a beer in next JavaOne :D?

Shai Almog

unread,
Feb 9, 2015, 1:02:26 PM2/9/15
to codenameone...@googlegroups.com, mikko.nu...@gmail.com
Not sure I'm going this year. Right now we have so many issues that adding additional ones doesn't really make me happy...
Reply all
Reply to author
Forward
0 new messages