Why is the grid not shown in this Vaadin 11.0.0 application?












0














I want to display two tabs (Providers and Products) in a Vaadin page. The Providers should contain a grid with one record.



I wrote the following code for this:



import java.util.ArrayList;
import java.util.List;

import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.tabs.Tab;
import com.vaadin.flow.component.tabs.Tabs;
import com.vaadin.flow.router.Route;

@Route("")
public class MainView extends VerticalLayout {

public MainView() {
final Text header = new Text("Header");
add(header);

final Tab productsTab = new Tab("Products");
final Tab providersTab = new Tab("Providers");
final Grid<LoanProvider> providersGrid = new Grid<>();
providersGrid.addColumn(LoanProvider::getName).setHeader("Name");
providersGrid.addColumn(LoanProvider::getRegions).setHeader("Regions");
providersGrid.addColumn(LoanProvider::getUrl).setHeader("URL");
providersGrid.setSizeFull();
providersTab.add(providersGrid);
final Tabs tabs = new Tabs(providersTab, productsTab);
add(tabs);
providersGrid.setItems(getLoanProviders());
}

private List<LoanProvider> getLoanProviders() {
final List<LoanProvider> coll = new ArrayList<>();
final LoanProvider sample = new LoanProvider();
sample.setName("Provider name");
sample.setRegions("Region1");
sample.setUrl("http://www.someserver.com");
coll.add(sample);
return coll;
}
}

public class LoanProvider {
private String name;
private String regions;
private String url;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getRegions() {
return regions;
}

public void setRegions(String regions) {
this.regions = regions;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}
}


When I run the application, I don't see any data in the Products tab:



Screenshot



How can I change the code in order for the grid contents to be displayed?



Calling setSizeFull and setting height didn't help.










share|improve this question






















  • I would suggest to edit the title to reflect better that the question is about tabs. I had this problem too when upgrading to flow, and this post would help more users if it was titled appropriately. Maybe "Why is my Tab content not shown in Vaadin Flow?". Thanks :)
    – Cashbee
    Dec 17 '18 at 13:59
















0














I want to display two tabs (Providers and Products) in a Vaadin page. The Providers should contain a grid with one record.



I wrote the following code for this:



import java.util.ArrayList;
import java.util.List;

import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.tabs.Tab;
import com.vaadin.flow.component.tabs.Tabs;
import com.vaadin.flow.router.Route;

@Route("")
public class MainView extends VerticalLayout {

public MainView() {
final Text header = new Text("Header");
add(header);

final Tab productsTab = new Tab("Products");
final Tab providersTab = new Tab("Providers");
final Grid<LoanProvider> providersGrid = new Grid<>();
providersGrid.addColumn(LoanProvider::getName).setHeader("Name");
providersGrid.addColumn(LoanProvider::getRegions).setHeader("Regions");
providersGrid.addColumn(LoanProvider::getUrl).setHeader("URL");
providersGrid.setSizeFull();
providersTab.add(providersGrid);
final Tabs tabs = new Tabs(providersTab, productsTab);
add(tabs);
providersGrid.setItems(getLoanProviders());
}

private List<LoanProvider> getLoanProviders() {
final List<LoanProvider> coll = new ArrayList<>();
final LoanProvider sample = new LoanProvider();
sample.setName("Provider name");
sample.setRegions("Region1");
sample.setUrl("http://www.someserver.com");
coll.add(sample);
return coll;
}
}

public class LoanProvider {
private String name;
private String regions;
private String url;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getRegions() {
return regions;
}

public void setRegions(String regions) {
this.regions = regions;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}
}


When I run the application, I don't see any data in the Products tab:



Screenshot



How can I change the code in order for the grid contents to be displayed?



Calling setSizeFull and setting height didn't help.










share|improve this question






















  • I would suggest to edit the title to reflect better that the question is about tabs. I had this problem too when upgrading to flow, and this post would help more users if it was titled appropriately. Maybe "Why is my Tab content not shown in Vaadin Flow?". Thanks :)
    – Cashbee
    Dec 17 '18 at 13:59














0












0








0







I want to display two tabs (Providers and Products) in a Vaadin page. The Providers should contain a grid with one record.



I wrote the following code for this:



import java.util.ArrayList;
import java.util.List;

import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.tabs.Tab;
import com.vaadin.flow.component.tabs.Tabs;
import com.vaadin.flow.router.Route;

@Route("")
public class MainView extends VerticalLayout {

public MainView() {
final Text header = new Text("Header");
add(header);

final Tab productsTab = new Tab("Products");
final Tab providersTab = new Tab("Providers");
final Grid<LoanProvider> providersGrid = new Grid<>();
providersGrid.addColumn(LoanProvider::getName).setHeader("Name");
providersGrid.addColumn(LoanProvider::getRegions).setHeader("Regions");
providersGrid.addColumn(LoanProvider::getUrl).setHeader("URL");
providersGrid.setSizeFull();
providersTab.add(providersGrid);
final Tabs tabs = new Tabs(providersTab, productsTab);
add(tabs);
providersGrid.setItems(getLoanProviders());
}

private List<LoanProvider> getLoanProviders() {
final List<LoanProvider> coll = new ArrayList<>();
final LoanProvider sample = new LoanProvider();
sample.setName("Provider name");
sample.setRegions("Region1");
sample.setUrl("http://www.someserver.com");
coll.add(sample);
return coll;
}
}

public class LoanProvider {
private String name;
private String regions;
private String url;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getRegions() {
return regions;
}

public void setRegions(String regions) {
this.regions = regions;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}
}


When I run the application, I don't see any data in the Products tab:



Screenshot



How can I change the code in order for the grid contents to be displayed?



Calling setSizeFull and setting height didn't help.










share|improve this question













I want to display two tabs (Providers and Products) in a Vaadin page. The Providers should contain a grid with one record.



I wrote the following code for this:



import java.util.ArrayList;
import java.util.List;

import com.vaadin.flow.component.Text;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.tabs.Tab;
import com.vaadin.flow.component.tabs.Tabs;
import com.vaadin.flow.router.Route;

@Route("")
public class MainView extends VerticalLayout {

public MainView() {
final Text header = new Text("Header");
add(header);

final Tab productsTab = new Tab("Products");
final Tab providersTab = new Tab("Providers");
final Grid<LoanProvider> providersGrid = new Grid<>();
providersGrid.addColumn(LoanProvider::getName).setHeader("Name");
providersGrid.addColumn(LoanProvider::getRegions).setHeader("Regions");
providersGrid.addColumn(LoanProvider::getUrl).setHeader("URL");
providersGrid.setSizeFull();
providersTab.add(providersGrid);
final Tabs tabs = new Tabs(providersTab, productsTab);
add(tabs);
providersGrid.setItems(getLoanProviders());
}

private List<LoanProvider> getLoanProviders() {
final List<LoanProvider> coll = new ArrayList<>();
final LoanProvider sample = new LoanProvider();
sample.setName("Provider name");
sample.setRegions("Region1");
sample.setUrl("http://www.someserver.com");
coll.add(sample);
return coll;
}
}

public class LoanProvider {
private String name;
private String regions;
private String url;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getRegions() {
return regions;
}

public void setRegions(String regions) {
this.regions = regions;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}
}


When I run the application, I don't see any data in the Products tab:



Screenshot



How can I change the code in order for the grid contents to be displayed?



Calling setSizeFull and setting height didn't help.







java grid vaadin






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 21:20









DP_

3,16132113228




3,16132113228












  • I would suggest to edit the title to reflect better that the question is about tabs. I had this problem too when upgrading to flow, and this post would help more users if it was titled appropriately. Maybe "Why is my Tab content not shown in Vaadin Flow?". Thanks :)
    – Cashbee
    Dec 17 '18 at 13:59


















  • I would suggest to edit the title to reflect better that the question is about tabs. I had this problem too when upgrading to flow, and this post would help more users if it was titled appropriately. Maybe "Why is my Tab content not shown in Vaadin Flow?". Thanks :)
    – Cashbee
    Dec 17 '18 at 13:59
















I would suggest to edit the title to reflect better that the question is about tabs. I had this problem too when upgrading to flow, and this post would help more users if it was titled appropriately. Maybe "Why is my Tab content not shown in Vaadin Flow?". Thanks :)
– Cashbee
Dec 17 '18 at 13:59




I would suggest to edit the title to reflect better that the question is about tabs. I had this problem too when upgrading to flow, and this post would help more users if it was titled appropriately. Maybe "Why is my Tab content not shown in Vaadin Flow?". Thanks :)
– Cashbee
Dec 17 '18 at 13:59












1 Answer
1






active

oldest

votes


















2














Tabs in Flow should not contain the page content, what you are doing now is adding the grid to the tab itself (right after the Providers text).



On this page there's an example Tabs with pages
https://vaadin.com/components/vaadin-tabs/java-examples



Basically you should add a SelectedChangeListener to the tabs component, and depending on which tab was clicked, show or hide the grid (either by setVisible or by removing it and re-adding it to the parent).



There is also an addon in Vaadin Directory that wraps similar logic of the above example
https://vaadin.com/directory/component/paged-tabs






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%2f53270292%2fwhy-is-the-grid-not-shown-in-this-vaadin-11-0-0-application%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









    2














    Tabs in Flow should not contain the page content, what you are doing now is adding the grid to the tab itself (right after the Providers text).



    On this page there's an example Tabs with pages
    https://vaadin.com/components/vaadin-tabs/java-examples



    Basically you should add a SelectedChangeListener to the tabs component, and depending on which tab was clicked, show or hide the grid (either by setVisible or by removing it and re-adding it to the parent).



    There is also an addon in Vaadin Directory that wraps similar logic of the above example
    https://vaadin.com/directory/component/paged-tabs






    share|improve this answer




























      2














      Tabs in Flow should not contain the page content, what you are doing now is adding the grid to the tab itself (right after the Providers text).



      On this page there's an example Tabs with pages
      https://vaadin.com/components/vaadin-tabs/java-examples



      Basically you should add a SelectedChangeListener to the tabs component, and depending on which tab was clicked, show or hide the grid (either by setVisible or by removing it and re-adding it to the parent).



      There is also an addon in Vaadin Directory that wraps similar logic of the above example
      https://vaadin.com/directory/component/paged-tabs






      share|improve this answer


























        2












        2








        2






        Tabs in Flow should not contain the page content, what you are doing now is adding the grid to the tab itself (right after the Providers text).



        On this page there's an example Tabs with pages
        https://vaadin.com/components/vaadin-tabs/java-examples



        Basically you should add a SelectedChangeListener to the tabs component, and depending on which tab was clicked, show or hide the grid (either by setVisible or by removing it and re-adding it to the parent).



        There is also an addon in Vaadin Directory that wraps similar logic of the above example
        https://vaadin.com/directory/component/paged-tabs






        share|improve this answer














        Tabs in Flow should not contain the page content, what you are doing now is adding the grid to the tab itself (right after the Providers text).



        On this page there's an example Tabs with pages
        https://vaadin.com/components/vaadin-tabs/java-examples



        Basically you should add a SelectedChangeListener to the tabs component, and depending on which tab was clicked, show or hide the grid (either by setVisible or by removing it and re-adding it to the parent).



        There is also an addon in Vaadin Directory that wraps similar logic of the above example
        https://vaadin.com/directory/component/paged-tabs







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 13 '18 at 7:32









        Tatu Lund

        2,271139




        2,271139










        answered Nov 13 '18 at 6:38









        Tazavoo

        768310




        768310






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53270292%2fwhy-is-the-grid-not-shown-in-this-vaadin-11-0-0-application%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

            Xamarin.iOS Cant Deploy on Iphone

            Glorious Revolution

            Dulmage-Mendelsohn matrix decomposition in Python