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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:26:58+00:00 2026-05-26T02:26:58+00:00

I have a form with a dataTable which has various columns having links and

  • 0

I have a form with a dataTable which has various columns having links and outputTexts. There is one input field which is evaluated through an ajax request . A custom validator makes sure that only integers are added to the field. The form is below.

    <form>  
            <h:dataTable var="item" value="#{listItems.model}" id="adminlistItems"> 
                //other columns having commandLinks and outputTexts
                    <h:column>
                        <f:facet name="header" >
                            <h:outputText value="Quantity"/>
                        </f:facet>                  
                        <f:ajax listener="#{listItems.AddQuantityAction}">
                            <div style="padding:5px;float:left">
                                <h:inputText label="changeQuantity" id="addquantity" value="#{item.additionalQuantity}" maxlength="4" size="3">
                                    <f:validator validatorId="integerValidator"/>
                                </h:inputText>
                                <h:outputText value="&nbsp;"/>
                                <h:commandButton value="AddQuantity"  />
                                <h:message for="addquantity"/>
                            </div>
                        </f:ajax>  
                    </h:column>
            </h:dataTable>
        </h:form>

The code for the bean is :

    @ViewScoped
    @ManagedBean
    public class ListItems implements Serializable {    
    //...
    public String AddQuantityAction(){
              //...
      boolean result = //some action
              FacesContext context=FacesContext.getCurrentInstance();
              UIComponent component=UIComponent.getCurrentComponent(context);
              String clientID=component.getClientId(context);
              if (result) {
                   FacesMessage message = new FacesMessage("Quantity added successfully");
                  FacesContext.getCurrentInstance().addMessage(clientID, message);
              } else {
                  FacesMessage message = new FacesMessage("Quantity not added.Processing error");
                  FacesContext.getCurrentInstance().addMessage(clientID, message);
              }
              return "adminListItems"; 
          }
      }

The custom validator throws a validator exception which is not displayed. And the listener also has code for messages which too are not displayed. I have read several similar questions and this sounds a common question too. But even if i am missing something obvious,i am in need of a third eye to see what i dont.

  • 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-26T02:26:59+00:00Added an answer on May 26, 2026 at 2:26 am

    The execute and render of <f:ajax> defaults to @this. So only the currently active component will be processed and refreshed. When you press the button, this won’t send the input value nor refresh the message component.

    Fix it accordingly:

    <f:ajax execute="addquantity" render="addquantity_message" listener="#{listItems.AddQuantityAction}">
        ...
        <h:message id="addquantity_message" for="addquantity"/>
        ...
    </f:ajax>
    

    By the way, why don’t you just use the builtin javax.faces.Integer converter instead of that validator?

    <h:inputText ... converter="javax.faces.Integer">
    

    Further, the return value of ajax listener methods should be void. It’s totally ignored in any way. Also, method names should start with lowercase. See also Java naming conventions.


    Update as per the comment, that didn’t seem to work out well with regard to validation. The listener is invoked 2 times because essentially 2 ajax requests are been sent, one for the input and one for the command. I suggest to move the listener method to the <h:commandButton action>.

    <f:ajax execute="addquantity" render="addquantity_message">
        ...
        <h:commandButton action="#{listItems.AddQuantityAction}" />
        <h:message id="addquantity_message" for="addquantity"/>
    </f:ajax>
    

    You’ll only fix the obtained client ID to be the input ID, not the button ID.

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

Sidebar

Related Questions

I have a DataTable, which has a number of columns. Some of those columns
Im using c# .net windows form application. I have created a database which has
I have a form which contains a DataGridView, a BindingSource, a DataTable, and a
I have a simple data table which contains dynamic form text fields. Each field
I have a form with some inputs which has a ViewScoped * ManagedBean *
I am connecting C# with Oracle 11g. I have a DataTable which i fill
I have found some similar questions like this one, however there are so many
Let's say that I have a form which runs a stored procedure. This stored
I have a Datagrid connected to Datatable, which needs to load a very large
I have this datatable with dynamic columns in my application. I'm trying to figure

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.