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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:10:35+00:00 2026-05-29T10:10:35+00:00

I am building an invoice application. When the user selects the client, then the

  • 0

I am building an invoice application. When the user selects the client, then the services associated with the client are re-rendered in a dataTable by an ajax event. But, the ajax event of the selectOneMenu in the dataTable does not fire.

This is the form which lets the user select a client:

<h:form>
    <h:selectOneMenu id="clientSelect" value="#{invoiceBean.client}">
        <f:ajax execute="clientSelect" listener="#{invoiceServiceListener.processClientValueChange}" render=":test :invoiceData"/>
        <f:selectItems value="#{invoiceBean.clientOptions}"/>
    </h:selectOneMenu>
</h:form>

This will fire an ajax event which fills the services array in the invoiceBean and re-renders the dataTable which displays the services in another selectOneMenu in the dataTable. This part works properly.

This is the datatable that is re-rendered after selecting the client by the above form:

<h:panelGroup id="test">
    <h:dataTable id="invoiceData" value="#{attributes.priceAttributes}" var="loop">
        <h:column>
            <ui:param name="service" value="service#{loop}" /> 
            <ui:param name="description" value="description#{loop}" />
            <ui:param name="price" value="price#{loop}" />
            <h:form id="invoiceSelectMenu">
                <h:selectOneMenu id="selectMenu" value="#{invoiceBean[service]}">
                    <f:ajax event="change" execute="selectMenu" listener="#{invoiceServiceListener.procesServiceValueChange}" render="@form" />
                    <f:attribute name="row" value="#{loop}" />
                    <f:selectItems value="#{invoiceBean.services}" />
                </h:selectOneMenu>
                <h:inputText id="description" value="#{invoiceBean[description]}" />
                <h:inputText id="price" value="#{invoiceBean[price]}" />
                <h:outputText value="#{loop}" />
            </h:form>
        </h:column>
    </h:dataTable>  
</h:panelGroup>

The selectOneMenu is filled properly. However, the ajax event in this select one menu does not work after it has been re-rendered by the first form. But, if I manually fill the services array without submitting the first form, then this ajax event executes normally. By the way, this ajax event also sets a value to the description and price input fields, which should be re-rendered when the event happens. The invoiceBean is request scoped.

  • 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-05-29T10:10:36+00:00Added an answer on May 29, 2026 at 10:10 am

    This is going to be tricky. Due to JSF spec issue 790, whenever you re-render some content containing another <h:form> using <f:ajax>, then its view state will get lost. To solve this, you’d basically need to reference the full client ID of another <h:form> inside <f:ajax> instead of some containing component. But you’ve basically multiple forms inside a <h:dataTable> which can’t be referenced by an absolute client ID.

    You’d need to rearrange the code to put the <h:form> outside the <h:dataTable> and change the <f:ajax> to execute only the necessary components.

    <h:form id="invoiceDataForm">
        <h:dataTable id="invoiceData" value="#{attributes.priceAttributes}" var="loop">
            <h:column>
                <ui:param name="service" value="service#{loop}" /> 
                <ui:param name="description" value="description#{loop}" />
                <ui:param name="price" value="price#{loop}" />
                <h:selectOneMenu id="selectMenu" value="#{invoiceBean[service]}">
                    <f:ajax execute="selectMenu,description,price" listener="#{invoiceServiceListener.procesServiceValueChange}" render="@form" />
                    <f:attribute name="row" value="#{loop}" />
                    <f:selectItems value="#{invoiceBean.services}" />
                </h:selectOneMenu>
                <h:inputText id="description" value="#{invoiceBean[description]}" />
                <h:inputText id="price" value="#{invoiceBean[price]}" />
                <h:outputText value="#{loop}" />
            </h:column>
        </h:dataTable>
    </h:panelGroup>
    

    and then reference it form the first form as follows:

    <f:ajax execute="clientSelect" listener="#{invoiceServiceListener.processClientValueChange}" render=":invoiceDataForm" />
    

    Note that some component libraries such as PrimeFaces have already workarounded/solved this in the component library specific ajax engine. So if it might happen that you’re already using PrimeFaces, you could also replace <f:ajax> of the first form by <p:ajax>.


    Unrelated to the concrete problem, the <f:attribute name="row" value="#{loop}" /> may not do what you expect it does. It will set null because <f:xxx> tags run during view build time, not during view render time tag. The #{loop} is not available during view build time. But that’s subject for a different question 🙂

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

Sidebar

Related Questions

Building a client-side swing application what should be notified on a bus (application-wide message
I am building an invoice system for a client and would like to give
Building a multilingual application that should work with the most prevalent global alphabets but
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
Building a new ASP.net application, and planning to separate DB, 'service' tier and Web/UI
Building an NSCharacter set to restrict a UITextField for entering user names. I want
I am building a Windows form application using .NET 3.5. I would like to
I'm building a very small web ERP application with PHP / mySQL / CodeIgniter
I'm building an ASP.Net/MVC application using SQL 2008 Developer edition and a DB in
I'm building an MVC web application that supports different types of messages between users.

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.