Navigate using p:selectOneMenu

后端 未结 3 865
小蘑菇
小蘑菇 2021-02-10 10:35

I\'m using a select one menu to do navigation to different parts of my site:

                      
    <         


        
3条回答
  •  名媛妹妹
    2021-02-10 11:18

    Use custom content with with therein a .

    Bean:

    private List pages;
    
    @PostConstruct
    public void init() {
        pages = new ArrayList();
        pages.add(new Page("Page 1", "/page1.xhtml"));
        pages.add(new Page("Page 2", "/page2.xhtml"));
        pages.add(new Page("Page 3", "/page3.xhtml"));
    }
    

    View:

    
        
        
            
        
    
    

    Note that this doesn't work with List nor individual entries. You really need to provide a List (wherein Entity is Page in the above example).

    This generates a

    with fullworthy and crawlable (and clickable!) elements.

    See also:

    • What is the difference between redirect and navigation/forward and when to use what?
    • How to navigate in JSF? How to make URL reflect current page (and not previous one)

    提交回复
    热议问题