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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:02:16+00:00 2026-05-22T19:02:16+00:00

In a datatable column how can i display a text for a number value

  • 0

In a datatable column how can i display a text for a number value which is retrieved from database.

for eg if the value for a colum from database is 2 , then i need to display “Cheese” in datatable. similarly if the value is 3 then i need to display “cake”.

  • 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-22T19:02:17+00:00Added an answer on May 22, 2026 at 7:02 pm

    You need to maintain a mapping of those values in the backing bean.

    private Map<Long, String> foods;
    
    public Bean() {
        foods = new HashMap<Long, String>();
        foods.put(1L, "Pizza");
        foods.put(2L, "Cheese");
        foods.put(3L, "Cake");
        // ...
    }
    
    public Map<Long, String> getFoods() { 
        return foods;
    }
    

    Then you can get it as follows

    <h:dataTable value="#{bean.items}" var="item">
        <h:column>
            <h:outputText value="#{bean.foods[item.number]}" />
        </h:column>
    </h:dataTable>
    

    Where #{item.number} should return the desired number as Long.

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

Sidebar

Related Questions

I currently use a DataTable to get results from a database which I can
I'm trying to display in column info from parent dataTable: Country (Id int, Name
I have a datatable which loops through a List and has a value column
In a .NET Datatable, the columns are Object types, which can include a datatable
I have a DataTable that has a boolean column called [Invalid]. I need to
I m trying loading data table from xml schema. I can see column names
I have a Datatable that contains a column called Tags, Tags can have values
I have got a datatable with records from two different database tables. Each of
I use repeater in my asp.net application to display records from database. The datasource
I am displaying values from database table using h:datatable, one tupple is displaying in

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.