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

  • Home
  • SEARCH
  • 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 6202417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:43:53+00:00 2026-05-24T04:43:53+00:00

I need to solve my problem with generating dynamic ID for some components in

  • 0

I need to solve my problem with generating dynamic ID for some components in JSF.

Have a look at this example:

<h:outputText id="#{bean.id}" value="#{bean.value}" />

My problem is that I am getting this error:

java.lang.IllegalArgumentException: Empty id attribute is not allowed

The ID of the component is empty when I look at generated HTML output. How is this caused and how can I solve it?

  • 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-24T04:43:54+00:00Added an answer on May 24, 2026 at 4:43 am

    You are right. I am using it inside datatable.

    Then this can happen if the #{bean} represents the currently iterated object as declared in var attribute like so:

    <h:dataTable value="#{someBean.beans}" var="bean">
        <h:column>
            <h:outputText id="#{bean.id}" value="#{bean.value}" />
    

    The id (and binding) attribute of a JSF component is evaluated during view build time, that moment when the JSF component tree needs to be composed. However, the #{bean} is only available during view render time, that moment when <h:dataTable> needs to iterate over all objects and generate HTML table rows for each of them. The #{bean} is thus not available during view build time and evaluates to null which ultimately gets EL-coerced to an empty string. And hence the exception java.lang.IllegalArgumentException: Empty id attribute is not allowed.

    You’ve basically 3 options:

    1. Use a view build time tag instead to iterate over a collection. You’d only need to write all HTML boilerplate yourself:

      <table>
          <c:forEach items="#{someBean.beans}" var="bean">
              <tr>
                  <td>
                      <h:outputText id="#{bean.id}" value="#{bean.value}" />
      
    2. Use a plain HTML element:

      <h:dataTable value="#{someBean.beans}" var="bean">
          <h:column>
              <span id="#{bean.id}">#{bean.value}</span>
      
    3. Don’t set a dynamic ID, but a fixed ID. JSF will ensure of uniqueness in HTML output by prepending it with row index of the table:

      <h:dataTable value="#{someBean.beans}" var="bean">
          <h:column>
              <h:outputText id="id" value="#{bean.value}" />
      

    See also:

    • JSTL in JSF2 Facelets… makes sense? (you can substitute “JSTL” with “dynamic ID”)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some ideas on how I can best solve this problem. I have
I don't like JSF but I need to solve this problem with it, I
Well i need some help here i don't know how to solve this problem.
I need help to solve this problem: I have a csv file like this
I need to solve a locking problem for this scenario: A multi CPU system.
To solve some problem I need to compute a variant of the pascal's triangle
This is a problem I've been struggling to solve for a while. I need
I need to solve a gender translation problem, and Django doesn't seem to have
I need to solve a problem. I have 5 devices. They all have 4
I need to solve this algorithm problem. In the diagram, there are many rows

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.