why does the navigation go to another in vaadin when i use navigator?












1















when i tried to go to another page using navigator he always go to this page, and if someone could help me with this:



http://localhost:8080/#!/index


and here is the code:



 @SpringUI(path = "/")
public class Mainview extends UI implements View {`

@Override
protected void init(VaadinRequest vaadinRequest) {
VerticalLayout contents = new VerticalLayout();
setContent(contents);

TextField username = new TextField("Email OR User Name");
username.setWidth("25%");
contents.addComponent(username);
contents.setComponentAlignment(username, Alignment.MIDDLE_CENTER);

TextField password = new TextField("password");
password.setWidth("25%");
contents.addComponent(password);
contents.setComponentAlignment(password, Alignment.MIDDLE_CENTER);

Button signButton = new Button("Sign In");
signButton.setWidth("15%");
contents.addComponent(signButton);
contents.setComponentAlignment(signButton, Alignment.BOTTOM_CENTER);

signButton.addClickListener(clickEvent -> {
Navigator navigator = new Navigator(getUI(), this);
navigator.addView("/", new Mainview());
navigator.addView("/index", new SecondPage());
navigator.navigateTo("/index");
});
}
}


and here is the other page:



@SpringUI(path = "/index")
public class SecondPage extends UI implements View {
@Override
protected void init(VaadinRequest vaadinRequest) {
VerticalLayout contents = new VerticalLayout();
setContent(contents);
Button button = new Button("hey");
button.setWidth("10%");
button.setHeight("10%");

contents.addComponent(button);
}


thank's for the helpers.










share|improve this question





























    1















    when i tried to go to another page using navigator he always go to this page, and if someone could help me with this:



    http://localhost:8080/#!/index


    and here is the code:



     @SpringUI(path = "/")
    public class Mainview extends UI implements View {`

    @Override
    protected void init(VaadinRequest vaadinRequest) {
    VerticalLayout contents = new VerticalLayout();
    setContent(contents);

    TextField username = new TextField("Email OR User Name");
    username.setWidth("25%");
    contents.addComponent(username);
    contents.setComponentAlignment(username, Alignment.MIDDLE_CENTER);

    TextField password = new TextField("password");
    password.setWidth("25%");
    contents.addComponent(password);
    contents.setComponentAlignment(password, Alignment.MIDDLE_CENTER);

    Button signButton = new Button("Sign In");
    signButton.setWidth("15%");
    contents.addComponent(signButton);
    contents.setComponentAlignment(signButton, Alignment.BOTTOM_CENTER);

    signButton.addClickListener(clickEvent -> {
    Navigator navigator = new Navigator(getUI(), this);
    navigator.addView("/", new Mainview());
    navigator.addView("/index", new SecondPage());
    navigator.navigateTo("/index");
    });
    }
    }


    and here is the other page:



    @SpringUI(path = "/index")
    public class SecondPage extends UI implements View {
    @Override
    protected void init(VaadinRequest vaadinRequest) {
    VerticalLayout contents = new VerticalLayout();
    setContent(contents);
    Button button = new Button("hey");
    button.setWidth("10%");
    button.setHeight("10%");

    contents.addComponent(button);
    }


    thank's for the helpers.










    share|improve this question



























      1












      1








      1








      when i tried to go to another page using navigator he always go to this page, and if someone could help me with this:



      http://localhost:8080/#!/index


      and here is the code:



       @SpringUI(path = "/")
      public class Mainview extends UI implements View {`

      @Override
      protected void init(VaadinRequest vaadinRequest) {
      VerticalLayout contents = new VerticalLayout();
      setContent(contents);

      TextField username = new TextField("Email OR User Name");
      username.setWidth("25%");
      contents.addComponent(username);
      contents.setComponentAlignment(username, Alignment.MIDDLE_CENTER);

      TextField password = new TextField("password");
      password.setWidth("25%");
      contents.addComponent(password);
      contents.setComponentAlignment(password, Alignment.MIDDLE_CENTER);

      Button signButton = new Button("Sign In");
      signButton.setWidth("15%");
      contents.addComponent(signButton);
      contents.setComponentAlignment(signButton, Alignment.BOTTOM_CENTER);

      signButton.addClickListener(clickEvent -> {
      Navigator navigator = new Navigator(getUI(), this);
      navigator.addView("/", new Mainview());
      navigator.addView("/index", new SecondPage());
      navigator.navigateTo("/index");
      });
      }
      }


      and here is the other page:



      @SpringUI(path = "/index")
      public class SecondPage extends UI implements View {
      @Override
      protected void init(VaadinRequest vaadinRequest) {
      VerticalLayout contents = new VerticalLayout();
      setContent(contents);
      Button button = new Button("hey");
      button.setWidth("10%");
      button.setHeight("10%");

      contents.addComponent(button);
      }


      thank's for the helpers.










      share|improve this question
















      when i tried to go to another page using navigator he always go to this page, and if someone could help me with this:



      http://localhost:8080/#!/index


      and here is the code:



       @SpringUI(path = "/")
      public class Mainview extends UI implements View {`

      @Override
      protected void init(VaadinRequest vaadinRequest) {
      VerticalLayout contents = new VerticalLayout();
      setContent(contents);

      TextField username = new TextField("Email OR User Name");
      username.setWidth("25%");
      contents.addComponent(username);
      contents.setComponentAlignment(username, Alignment.MIDDLE_CENTER);

      TextField password = new TextField("password");
      password.setWidth("25%");
      contents.addComponent(password);
      contents.setComponentAlignment(password, Alignment.MIDDLE_CENTER);

      Button signButton = new Button("Sign In");
      signButton.setWidth("15%");
      contents.addComponent(signButton);
      contents.setComponentAlignment(signButton, Alignment.BOTTOM_CENTER);

      signButton.addClickListener(clickEvent -> {
      Navigator navigator = new Navigator(getUI(), this);
      navigator.addView("/", new Mainview());
      navigator.addView("/index", new SecondPage());
      navigator.navigateTo("/index");
      });
      }
      }


      and here is the other page:



      @SpringUI(path = "/index")
      public class SecondPage extends UI implements View {
      @Override
      protected void init(VaadinRequest vaadinRequest) {
      VerticalLayout contents = new VerticalLayout();
      setContent(contents);
      Button button = new Button("hey");
      button.setWidth("10%");
      button.setHeight("10%");

      contents.addComponent(button);
      }


      thank's for the helpers.







      java vaadin8






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 24 '18 at 13:52







      Barel13

















      asked Nov 24 '18 at 11:43









      Barel13Barel13

      104




      104
























          1 Answer
          1






          active

          oldest

          votes


















          1














          The reason is quite simple, the other UI is deployed at URL http://localhost:8080/index not http://localhost:8080/#!/index. You seem to have a misconception about Navigator. Navigator is made for within UI navigation, i.e. navigation between views, not between UI's.



          I assume you actually do not want to define the SecondPage as another UI, but as another view. So you should not extend UI there. Also as you are using Spring DI there, you should define it as @SpringView. And as you do so, you do not need to register it via Navigator.addView(..) method, since Spring add-on will auto register all @SpringView annotated views to view provider automatically. So you should just autowire the view provider and set the view provider of the Navigator.



          There is more documentation with examples here: https://vaadin.com/docs/v8/framework/advanced/advanced-spring.html






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457764%2fwhy-does-the-navigation-go-to-another-in-vaadin-when-i-use-navigator%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            The reason is quite simple, the other UI is deployed at URL http://localhost:8080/index not http://localhost:8080/#!/index. You seem to have a misconception about Navigator. Navigator is made for within UI navigation, i.e. navigation between views, not between UI's.



            I assume you actually do not want to define the SecondPage as another UI, but as another view. So you should not extend UI there. Also as you are using Spring DI there, you should define it as @SpringView. And as you do so, you do not need to register it via Navigator.addView(..) method, since Spring add-on will auto register all @SpringView annotated views to view provider automatically. So you should just autowire the view provider and set the view provider of the Navigator.



            There is more documentation with examples here: https://vaadin.com/docs/v8/framework/advanced/advanced-spring.html






            share|improve this answer




























              1














              The reason is quite simple, the other UI is deployed at URL http://localhost:8080/index not http://localhost:8080/#!/index. You seem to have a misconception about Navigator. Navigator is made for within UI navigation, i.e. navigation between views, not between UI's.



              I assume you actually do not want to define the SecondPage as another UI, but as another view. So you should not extend UI there. Also as you are using Spring DI there, you should define it as @SpringView. And as you do so, you do not need to register it via Navigator.addView(..) method, since Spring add-on will auto register all @SpringView annotated views to view provider automatically. So you should just autowire the view provider and set the view provider of the Navigator.



              There is more documentation with examples here: https://vaadin.com/docs/v8/framework/advanced/advanced-spring.html






              share|improve this answer


























                1












                1








                1







                The reason is quite simple, the other UI is deployed at URL http://localhost:8080/index not http://localhost:8080/#!/index. You seem to have a misconception about Navigator. Navigator is made for within UI navigation, i.e. navigation between views, not between UI's.



                I assume you actually do not want to define the SecondPage as another UI, but as another view. So you should not extend UI there. Also as you are using Spring DI there, you should define it as @SpringView. And as you do so, you do not need to register it via Navigator.addView(..) method, since Spring add-on will auto register all @SpringView annotated views to view provider automatically. So you should just autowire the view provider and set the view provider of the Navigator.



                There is more documentation with examples here: https://vaadin.com/docs/v8/framework/advanced/advanced-spring.html






                share|improve this answer













                The reason is quite simple, the other UI is deployed at URL http://localhost:8080/index not http://localhost:8080/#!/index. You seem to have a misconception about Navigator. Navigator is made for within UI navigation, i.e. navigation between views, not between UI's.



                I assume you actually do not want to define the SecondPage as another UI, but as another view. So you should not extend UI there. Also as you are using Spring DI there, you should define it as @SpringView. And as you do so, you do not need to register it via Navigator.addView(..) method, since Spring add-on will auto register all @SpringView annotated views to view provider automatically. So you should just autowire the view provider and set the view provider of the Navigator.



                There is more documentation with examples here: https://vaadin.com/docs/v8/framework/advanced/advanced-spring.html







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 24 '18 at 18:18









                Tatu LundTatu Lund

                2,381139




                2,381139






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457764%2fwhy-does-the-navigation-go-to-another-in-vaadin-when-i-use-navigator%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Contact image not getting when fetch all contact list from iPhone by CNContact

                    count number of partitions of a set with n elements into k subsets

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks