Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 480445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T00:53:37+00:00 2026-05-13T00:53:37+00:00

I have a selectonemenu where a change in the selection should navigate the user

  • 0

I have a selectonemenu where a change in the selection should navigate the user to the related page.

So, how do I simulate the action handling of a commandbutton using a selectonemenu control (or are there a more elegant ways to achieve this)?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T00:53:37+00:00Added an answer on May 13, 2026 at 12:53 am

    You can’t go around a shot of Javascript for this. Basically you need to let the Javascript submit the request to the server side. In a HTML <select> element (which is been generated by the JSF h:selectOneMenu) you can best use the onchange attribute for this. Any JS which you attach to this event will be invoked whenever the user changes the value of the element.

    <h:selectOneMenu onchange="this.form.submit();">
    

    or if you’re lazy in writing, this shorthand is also correct:

    <h:selectOneMenu onchange="submit()">
    

    This will submit the form in combination with the firstnext HTML input type="submit" element inside the same form (which is been generated by the JSF h:commandButton).

    <h:form>
        <h:selectOneMenu value="#{bean.page}" onchange="submit()" required="true">
            <f:selectItem itemLabel="Select page.." />
            <f:selectItems value="#{bean.pages}" />
        </h:selectOneMenu>
        <h:commandButton value="submit" action="#{bean.submit}" />
        <h:commandButton value="other" action="#{bean.other}" /> <!-- won't be submitted -->
    </h:form>
    

    You need to write logic in the action method which causes the navigation action as definied in faces-config.xml to be taken place. Example:

    public String submit() {
        return this.page;
    }
    

    If you do not want to use an commandButton, then you can also go ahead with abusing the valueChangeListener:

    <h:form>
        <h:selectOneMenu value="#{bean.page}" onchange="submit()"
            valueChangeListener="#{bean.change}" required="true">
            <f:selectItem itemLabel="Select page.." />
            <f:selectItems value="#{bean.pages}" />
        </h:selectOneMenu>
    </h:form>
    

    In the bean you then have:

    public void change(ValueChangeEvent event) {
        String page = (String) event.getNewValue(); // Must however be the exact page URL. E.g. "contact.jsf".
        FacesContext.getCurrentInstance().getExternalContext().redirect(page);
    }
    

    Alternatively, if you already have the desired URL’s as f:selectItem values, then you can also go ahead with just only JS and no bean actions:

    <h:selectOneMenu value="#{bean.page}"
        onchange="window.location = this.options[this.selectedIndex].value">
        <f:selectItem itemLabel="Select page.." />
        <f:selectItem itemLabel="home" itemValue="home.jsf" />
        <f:selectItem itemLabel="faq" itemValue="faq.jsf" />
        <f:selectItem itemLabel="contact" itemValue="contact.jsf" />
    </h:selectOneMenu>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a create new user jsf page, I have a SelectOneMenu with a custom
I have a Primefaces dataTable with rowEdit. Two columns contain a selectOneMenu control in
I have a JSF1.2 selectOneMenu component. Currently, a user selects an item from the
I have 2 <h:selectOneMenu> components and one of them depends of the selection of
I have a page with a <h:selectOneMenu> and I want to show some fields
I want to have multiple <h:selectOneMenu> that are displayed by selection of main <h:selectOneMenu>
Hi i have created a custom converter in jsf for combo box using h:selectOneMenu,
I have some JSF-trouble using h:selectOneMenu with a list from my backend bean: My
I have jsf page: .... <form jsfc=h:form action=> <h:dataTable value=#{newMusician.strings} var=preferredMusicGenre id=musicGenresSelectTable> <h:column> <h:inputText
I am using JSF 2.0 and PrimeFaces. I have a selectOneMenu and a selectManyCheckbox.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.