How to call post show Form method ?

30 views
Skip to first unread message

sanket patel

unread,
Jul 2, 2016, 3:25:55 PM7/2/16
to CodenameOne Discussions
Hi Shai,

I have created left Side Menu and in that added Navigation Commands having separate form instantiated. When I click command it will show respective form. My problem is that this sideMenu is in my landing page only, and when this landing page show, all the forms are instantiated and call its respective services, which is no meaning. Services of each form will be call when I click on navigation command of that form and when that form shows. Is there any way I can call that serviced in post showing form and load data in that form?



If you are experiencing an issue please mention the full platform your issue applies to:
IDE: NetBeans/Eclipse/IDEA
Desktop OS
Simulator
Device

Shai Almog

unread,
Jul 3, 2016, 1:22:59 AM7/3/16
to CodenameOne Discussions
Hi,
I don't quite understand the question but I'm guessing that you want one menu for all the forms in a GUI builder application?

Just create an "initMenu(Form)" method and call it from the before event of all forms. It will build your unified menu.

sanket patel

unread,
Jul 3, 2016, 1:34:56 AM7/3/16
to codenameone...@googlegroups.com
No Shai,

What is the best way to create sideMenu and calling each form? See what I did that, created NavigationCommand and in that I did li e, navigationCommand.nextForm(new MyForm()), But my problem is that this MyForm() is called on menu creation time. And in MyForm() I have to call service which get all the data from server. I dont want that this service called unnecessarily time of menu creation.

I want something that my service will be called on the time when form's show method called.





Sanket

--
You received this message because you are subscribed to a topic in the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codenameone-discussions/qhoZvPKzKRY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/4a922967-40c6-4c4d-a528-2f8260cc794b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shai Almog

unread,
Jul 4, 2016, 12:02:43 AM7/4/16
to CodenameOne Discussions
The mistake is doing the network connection on construction instead of when the form is shown. Forms have a show event that you can override or listen to.
Reply all
Reply to author
Forward
0 new messages