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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:22:32+00:00 2026-06-04T00:22:32+00:00

I am using primefaces 3.2. I’ve got the following situation: <h:form id=someForm> .. <p:dataTable

  • 0

I am using primefaces 3.2.

I’ve got the following situation:

<h:form id="someForm">
  ..
  <p:dataTable id="someDataTable" value="#{BackingBean.list}" var="element" ..>
    <p:column>
      <p:calendar id="someCalendar" value=#{element.date} ../>
      <p:message id="someCalendarMessage" for=":someForm:someDataTable:someCalendar"/>
    <p:column>
  </p:dataTable>    
  ..
</h:form>

The “someDataTable” is updated dynamically and then all the data are submitted to the server side. In the backing bean I want to send message for calendar “someCalendar” if the entered date doesn’t satisfy some condition. I try to find the component using this code:

FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.addMessage(facesContext.getViewRoot().findComponent(":someForm:someDataTable:" + "i" + ":someCalendar").getClientId(), new FacesMessage(FacesMessage.SEVERITY_ERROR, Utils.getResourceBundleString("dictionary", "error") + ":", Utils.getResourceBundleString("dictionary", "some_message")));
return;

Where i is the index of the “element” in the dataTable which the same as index in the list located in the BackingBean.

The problem is that I get NullPointerException since the facesContext.getViewRoot().findComponent(..) method cannot find the component, although I checked the generated id of the calendar in the view and it is
:someForm:someDataTable:0:someCalendar for the first element and it should be :someForm:someDataTable:1:someCalendar for the next element etc.

Why the facesContext.getViewRoot().findComponent(..) method cannot find the component inside the ? The is updated dynamically and maybe the server side doesn’t get the updated component tree after submission is done?

Thanks in advance.

  • 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-04T00:22:34+00:00Added an answer on June 4, 2026 at 12:22 am

    This is because the p:dataTable is a repeated component and during view build time there is only one calendar in the view root. It has the id someForm:someDataTable:someCalendar.

    Only during view render time the table rows are created and the row-dependent ids generated.

    You should use JSF build-in validation facilities to check your dates:

    in the view:

    <p:calendar id="someCalendar" value=#{element.date} 
                validator="#{BackinBean.validateDate}"/>
    <p:message id="someCalendarMessage" for="someCalendar"/>
    

    (someCalendar in the for attribute is sufficient)

    and in the backing bean:

    public void validateDate(
                   FacesContext context, 
                   UIComponent component, 
                   Object value) throws ValidatorException {
    
            if (/* date is not valid */) {
                throw new ValidatorException(
                   new FacesMessage("Date is not valid"));
            }
    
    }
    

    The FacesMessage from the validation method will automatically be displayed in the correct table row.

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

Sidebar

Related Questions

I'm using primefaces and jstl to loop a datatable.I have a List in backing
We are using Primefaces 3M4 and one of our pages has a p:dataTable which
As can be seen here: primefaces scrolling DataTable And in the image: When using
I am using primefaces datatable. How to set width when the table is empty
I'm using Primefaces 3.0.RC1 and on a form I have a <p:fileUpload mode=advanced auto=true>
I am using Primefaces 3.0. I have a datatable with selectionMode single as shown
i'm making a JSF2.0 project using mojarra primefaces tomcat6.x. I made a select list
I'm using JSF Primefaces 3.0.M3. When I submit (Save) a form some of the
I am trying to create a datatable using JSF primefaces. I know there is
I'm using Primefaces 2.2.1 and JSF 2.0 and I'm trying to show a list

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.