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 8829979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:57:40+00:00 2026-06-14T07:57:40+00:00

I want to update a selectOneMenu in form1 after submitting the commandbutton in form2.

  • 0

I want to update a selectOneMenu in form1 after submitting the commandbutton in form2. It is now only visible after a refresh of the page.

I have a selectOneMenu in form 1:

<h:form id="form1" rendered="#">

            <p:spacer height="30" />
            <h:selectOneMenu id="oneMenu" value="#{bean.value}">
                <f:selectItem itemLabel="Select Value" itemValue="" />
                <f:selectItems id="itemValues"
                    value="#{bean.allItems}" var="allItems"
                    itemValue="#{allItems}" itemLabel="#{allItems.name}" />
            </h:selectOneMenu>

and a DialogBOX in form2:

<h:form id="form2">
            <p:dialog header="Create new Item" widgetVar="newItem"
                resizable="false">

                <h:panelGrid columns="2" style="margin-bottom:10px">

                    <h:outputLabel for="item" value="Itemname:" />
                    <p:inputText id="itemname" value="#{bean.itemName}" />
                </h:panelGrid>

                <p:commandButton value="Submit"
                    actionListener="#{bean.newItem}"
                    update="form1:oneMenu" oncomplete="newItem.hide();"  />

            </p:dialog>

I’ve tried update="form1:oneMenu" but it doesn’t work. I’ve also read this post
but it doesn’t work either.

Thanks for help.

  • 1 1 Answer
  • 0 Views
  • 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-06-14T07:57:41+00:00Added an answer on June 14, 2026 at 7:57 am

    Make sure to use update=":form1:myPanel".

    Example :

    <h:form id="form1">
        <h:selectOneMenu id="oneMenu" value="#{bean.value}">
        ...
        </h:selectOneMenu>
    </h:form>
    
    <h:form id="form2">
        <p:dialog ..>
            ...
            <p:commandButton value="Submit" update=":form1:oneMenu" ..../>
        </p:dialog>
    </h:form>
    

    Otherwise

    <h:form id="form1">
        <p:selectOneMenu id="oneMenu" value="#{bean.value}">
        ...
        </p:selectOneMenu>
    </h:form>
    
    <h:form id="form2">
        <p:dialog ..>
            ...
            <p:commandButton value="Submit" update=":form1:oneMenu" ..../>
        </p:dialog>
    </h:form>
    

    Update For Comment : Try that below. You can use h:selectOneMenu or p:selectOneMenu.

    <h:form id="form1">
        <p:selectOneMenu style="width:195px;" required="true" id="cityMenu">
            <f:selectItems value="#{SelectOneMenuBean.cities}"/>
        </p:selectOneMenu>
        <p:commandButton oncomplete="newItem.show()" value="Show Dialog"/>
    </h:form>
    <h:form id="form2">
        <p:dialog header="Create new Item" widgetVar="newItem" resizable="false">
            <h:panelGrid columns="2" style="margin-bottom:10px">
                <h:outputLabel for="item" value="Itemname:" />
                <p:inputText id="itemname" value="#{SelectOneMenuBean.selectedValue}" />
            </h:panelGrid>
    
            <p:commandButton value="Submit" update=":form1:cityMenu" oncomplete="newItem.hide();"  />
    
        </p:dialog>     
    </h:form>
    
    public class SelectOneMenuBean {
        private String selectedValue;
    
        public String getSelectedValue() {
            return selectedValue;
        }
    
        public void setSelectedValue(String selectedValue) {
            this.selectedValue = selectedValue;
        }
    
        public String[] getCities() {
            if(selectedValue != null && selectedValue.equals("AAA")) {
                return new String[] {"City_1 of AAA", "City_2 of AAA", "City_3 of AAA"};
            } else if(selectedValue != null && selectedValue.equals("BBB")) {
                return new String[] {"City_1 of BBB", "City_2 of BBB", "City_3 of BBB"};
            } else if(selectedValue != null && selectedValue.equals("CCC")) {
                return new String[] {"City_1 of CCC", "City_2 of CCC", "City_3 of CCC"};
            } else if(selectedValue != null && selectedValue.equals("DDD")) {
                return new String[] {"City_1 of DDD", "City_2 of DDD", "City_3 of DDD"};
            } 
            return new String[] {"No City"};
        }
    }
    

    Note : If you input value AAA,BBB,CCC and DDD in dialog, the values of selectedOneMenu will be changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a problem with ajax update .From a SelectOneMenu component i want to
i have ios application with xcdatamodeld, i want update some data so need a
I have developed a windows forms c# application, i just want update items in
I want to update an erb.html page in rails with information from a webscraping
I have three drop down list <h:selectOneMenu> , and a <p:dataTable> . I want
i want update my row and concat my string but i have an error
I have table: test and field called: id. I want update time (ex. add
I want to update the second SelectOneMenu when I select any item of the
I want to update a document using the inbound form fields from req.body without
I want to update data in a database, in page update that is, adding

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.