Touchkit NavigationButton

Hi,

I used a navigationbutton in my navigationview. I want validation control in navigationbutton click event. If the process is valid then I want to navigate “XYZ” view, or it isn’t valid I want to show a message.
But,
There is a problem here.

NavigationButton navigationButton = new NavigationButton(“XYZ”);
navigationButton.addClickListener(new NavigationButtonClickListener() {

        @Override
        public void buttonClick(NavigationButtonClickEvent event) {
            try {
                   /*  in the code below I want to process to be stopped. I want to navigation view not to be navigated. But I don't know why the process is continued.  And I am seeing empty view.  The thing that I want is navigating to a view after I validate it. */
                   if (!"a".equals("b")) {
                    Notification.show("a is not equal to b");
                    return;
                   }
                
                /* process continues here
                .......
               */
               getNavigationManager().navigateTo(new XyzView());
               /* No problem here */ 
             } catch (Exception e) {
                Notification.show("Try Catch Error");
            }
        }
    });

Hi,

I suspect NavigationButton is not suitable for your purpose. It’s purpose is to initiate the view change animation to the next view immediately when the user taps the button, so that the animation occurs simultaneously while the mobile device is making the server request to get the actual content for the next view. The purpose of the server-side listener is to provide the new view by the time the animation finishes.

So you can’t prevent the view change animation from happening in the server-side listener, as it has already started at that time. Not calling navigateTo() in the listener probably just leaves the view empty, as you have observed, so you must call it. Well, you could navigateTo() to the same view where the user was in, but it would probably look odd.

Hence, I suggest that you use just an ordinary Button. I’m not immediately sure how it’s styled in the TouchKit theme… It’s styled like the NavigationButton at least in some contexts.